####################################
# Code to Replicate Charts Figures and Tables
# Trust in Public Policy Algorithms
# Journal of Politics
# Criminal Justice Experiments
# Study 3
# Ryan Kennedy, Philip D. Waggoner, and Matthew Ward
# 2021
####################################

#### Load needed libraries
library(tidyverse)
library(here)
library(clusterSEs)
library(stargazer)

#### Load data from experiments
conjoint <- read_csv(here("ConjointExperiment1.csv"))
conjoint2 <- read_csv(here("ConjointExperiment2.csv"))
conjoint3 <- read_csv(here("ConjointExperiment3.csv"))

#### Get demographic characteristics of samples
# Summary statistics for Table A3 in SI
csum <- conjoint %>%
  filter(Finished == 1) %>%
  select(gender, age, education, partisanid, leanpid, strongpid) %>%
  mutate(female = ifelse(gender == "Female", 1, 0),
         age = ifelse(age == 2626, 26, age),
         edvalue = case_when(education == "Elementary or some high school" ~ 1,
                             education == "High school graduate/GED" ~ 2,
                             education == "Trade or vocational certification" ~ 2,
                             education == "Some college, or an associate degree" ~ 3,
                             education == "Bachelor's degree (for example, BA, AB, BS)" ~ 3,
                             education == "Some graduate school" ~ 4,
                             education == "Master's degree (for example, MA, MSW, MBA)" ~ 4,
                             education == "Professional degree (for example, MD, JD, DDS)" ~ 4,
                             education == "Doctoral degree (for example, PhD, EdD)" ~ 4),
         partisanship = case_when(leanpid == "I lean neither way" ~ 4,
                                  leanpid == "Lean Democrat" ~ 3,
                                  leanpid == "Lean Republican" ~ 5,
                                  partisanid == "Republican" & strongpid == "No, NOT strongly" ~ 6,
                                  partisanid == "Democrat" & strongpid == "No, NOT strongly" ~ 2,
                                  partisanid == "Republican" & strongpid == "Yes, strongly" ~ 7,
                                  partisanid == "Democrat" & strongpid == "Yes, strongly" ~ 1)) %>%
  select(age, edvalue, female, partisanship)

csum2 <- conjoint2 %>%
  filter(Finished == 1) %>%
  select(gender, age, education, political_party) %>%
  mutate(female = ifelse(gender == 2, 1, 0),
         edvalue = case_when(education == 1 ~ 1,
                             education == 2 ~ 2,
                             education == 3 ~ 2,
                             education == 4 ~ 3,
                             education == 5 ~ 3,
                             education == 6 ~ 3,
                             education == 7 ~ 4,
                             education == 8 ~ 4),
         partisanship = case_when(political_party == 7 | political_party == 4 ~ 4,
                                  political_party == 6 | political_party == 3 ~ 3,
                                  political_party == 8 | political_party == 5 ~ 5,
                                  political_party == 9 ~ 6,
                                  political_party == 2 ~ 2,
                                  political_party == 10 ~ 7,
                                  political_party == 1 ~ 1)) %>%
  select(age, edvalue, female, partisanship)

csum3 <- conjoint3 %>%
  filter(Finished == 1) %>%
  select(gender, age, education, political_party) %>%
  mutate(female = ifelse(gender == 2, 1, 0),
         edvalue = case_when(education == 1 ~ 1,
                             education == 2 ~ 2,
                             education == 3 ~ 2,
                             education == 4 ~ 3,
                             education == 5 ~ 3,
                             education == 6 ~ 3,
                             education == 7 ~ 4,
                             education == 8 ~ 4),
         partisanship = case_when(political_party == 7 | political_party == 4 ~ 4,
                                  political_party == 6 | political_party == 3 ~ 3,
                                  political_party == 8 | political_party == 5 ~ 5,
                                  political_party == 9 ~ 6,
                                  political_party == 2 ~ 2,
                                  political_party == 10 ~ 7,
                                  political_party == 1 ~ 1)) %>%
  select(age, edvalue, female, partisanship)

csum <- csum %>%
  bind_rows(csum2, csum3)

csum <- data.frame(csum)

sink(here("conjointSummaries.tex"))
stargazer(csum, style = "ajps", 
          title = "Summary Statistics", 
          covariate.labels = c("Age","Education", "Female","Partisanship")
)
sink()



#### Recode the choice variable
conjoint <- conjoint %>%
  mutate(c1c1 = ifelse(C1_1 == "Choice 1", 1, 0),
         c1c2 = ifelse(C1_1 == "Choice 2", 1, 0),
         c2c1 = ifelse(C2_1 == "Choice 1", 1, 0),
         c2c2 = ifelse(C2_1 == "Choice 2", 1, 0),
         c3c1 = ifelse(C3_1 == "Choice 1", 1, 0),
         c3c2 = ifelse(C3_1 == "Choice 2", 1, 0),
         c4c1 = ifelse(C4_1 == "Choice 1", 1, 0),
         c4c2 = ifelse(C4_1 == "Choice 2", 1, 0),
         c5c1 = ifelse(C5_1 == "Choice 1", 1, 0),
         c5c2 = ifelse(C5_1 == "Choice 2", 1, 0)) %>%
  mutate(c11n = case_when(C11 == "1 Definitely Would Not Use" ~1,
                          C11 == "2" ~ 2,
                          C11 == "3" ~ 3,
                          C11 == "4" ~ 4,
                          C11 == "5" ~ 5,
                          C11 == "6" ~ 6,
                          C11 == "7 Definitely Would Use" ~ 7),
         c12n = case_when(C12 == "1 Definitely Would Not Use" ~1,
                          C12 == "2" ~ 2,
                          C12 == "3" ~ 3,
                          C12 == "4" ~ 4,
                          C12 == "5" ~ 5,
                          C12 == "6" ~ 6,
                          C12 == "7 Definitely Would Use" ~ 7),
         c21n = case_when(C21 == "1 Definitely Would Not Use" ~1,
                          C21 == "2" ~ 2,
                          C21 == "3" ~ 3,
                          C21 == "4" ~ 4,
                          C21 == "5" ~ 5,
                          C21 == "6" ~ 6,
                          C21 == "7 Definitely Would Use" ~ 7),
         c22n = case_when(C22 == "1 Definitely Would Not Use" ~1,
                          C22 == "2" ~ 2,
                          C22 == "3" ~ 3,
                          C22 == "4" ~ 4,
                          C22 == "5" ~ 5,
                          C22 == "6" ~ 6,
                          C22 == "7 Definitely Would Use" ~ 7),
         c31n = case_when(C31 == "1 Definitely Would Not Use" ~1,
                          C31 == "2" ~ 2,
                          C31 == "3" ~ 3,
                          C31 == "4" ~ 4,
                          C31 == "5" ~ 5,
                          C31 == "6" ~ 6,
                          C31 == "7 Definitely Would Use" ~ 7),
         c32n = case_when(C32 == "1 Definitely Would Not Use" ~1,
                          C32 == "2" ~ 2,
                          C32 == "3" ~ 3,
                          C32 == "4" ~ 4,
                          C32 == "5" ~ 5,
                          C32 == "6" ~ 6,
                          C32 == "7 Definitely Would Use" ~ 7),
         c41n = case_when(C41 == "1 Definitely Would Not Use" ~1,
                          C41 == "2" ~ 2,
                          C41 == "3" ~ 3,
                          C41 == "4" ~ 4,
                          C41 == "5" ~ 5,
                          C41 == "6" ~ 6,
                          C41 == "7 Definitely Would Use" ~ 7),
         c42n = case_when(C42 == "1 Definitely Would Not Use" ~1,
                          C42 == "2" ~ 2,
                          C42 == "3" ~ 3,
                          C42 == "4" ~ 4,
                          C42 == "5" ~ 5,
                          C42 == "6" ~ 6,
                          C42 == "7 Definitely Would Use" ~ 7),
         c51n = case_when(C51 == "1 Definitely Would Not Use" ~1,
                          C51 == "2" ~ 2,
                          C51 == "3" ~ 3,
                          C51 == "4" ~ 4,
                          C51 == "5" ~ 5,
                          C51 == "6" ~ 6,
                          C51 == "7 Definitely Would Use" ~ 7),
         c52n = case_when(C52 == "1 Definitely Would Not Use" ~1,
                          C52 == "2" ~ 2,
                          C52 == "3" ~ 3,
                          C52 == "4" ~ 4,
                          C52 == "5" ~ 5,
                          C52 == "6" ~ 6,
                          C52 == "7 Definitely Would Use" ~ 7)) %>%
  mutate(c11c = ifelse(c11n > 4, 1, 0),
         c12c = ifelse(c12n > 4, 1, 0),
         c21c = ifelse(c21n > 4, 1, 0),
         c22c = ifelse(c22n > 4, 1, 0),
         c31c = ifelse(c31n > 4, 1, 0),
         c32c = ifelse(c32n > 4, 1, 0),
         c41c = ifelse(c41n > 4, 1, 0),
         c42c = ifelse(c42n > 4, 1, 0),
         c51c = ifelse(c51n > 4, 1, 0),
         c52c = ifelse(c52n > 4, 1, 0))

conjoint2 <- conjoint2 %>%
  mutate(c1c1 = ifelse(C1_1 == "Choice 1", 1, 0),
         c1c2 = ifelse(C1_1 == "Choice 2", 1, 0),
         c2c1 = ifelse(C2_1 == "Choice 1", 1, 0),
         c2c2 = ifelse(C2_1 == "Choice 2", 1, 0),
         c3c1 = ifelse(C3_1 == "Choice 1", 1, 0),
         c3c2 = ifelse(C3_1 == "Choice 2", 1, 0),
         c4c1 = ifelse(C4_1 == "Choice 1", 1, 0),
         c4c2 = ifelse(C4_1 == "Choice 2", 1, 0),
         c5c1 = ifelse(C5_1 == "Choice 1", 1, 0),
         c5c2 = ifelse(C5_1 == "Choice 2", 1, 0)) %>%
  mutate(c11n = case_when(C11 == "1 Definitely Would Not Use" ~1,
                          C11 == "2" ~ 2,
                          C11 == "3" ~ 3,
                          C11 == "4" ~ 4,
                          C11 == "5" ~ 5,
                          C11 == "6" ~ 6,
                          C11 == "7 Definitely Would Use" ~ 7),
         c12n = case_when(C12 == "1 Definitely Would Not Use" ~1,
                          C12 == "2" ~ 2,
                          C12 == "3" ~ 3,
                          C12 == "4" ~ 4,
                          C12 == "5" ~ 5,
                          C12 == "6" ~ 6,
                          C12 == "7 Definitely Would Use" ~ 7),
         c21n = case_when(C21 == "1 Definitely Would Not Use" ~1,
                          C21 == "2" ~ 2,
                          C21 == "3" ~ 3,
                          C21 == "4" ~ 4,
                          C21 == "5" ~ 5,
                          C21 == "6" ~ 6,
                          C21 == "7 Definitely Would Use" ~ 7),
         c22n = case_when(C22 == "1 Definitely Would Not Use" ~1,
                          C22 == "2" ~ 2,
                          C22 == "3" ~ 3,
                          C22 == "4" ~ 4,
                          C22 == "5" ~ 5,
                          C22 == "6" ~ 6,
                          C22 == "7 Definitely Would Use" ~ 7),
         c31n = case_when(C31 == "1 Definitely Would Not Use" ~1,
                          C31 == "2" ~ 2,
                          C31 == "3" ~ 3,
                          C31 == "4" ~ 4,
                          C31 == "5" ~ 5,
                          C31 == "6" ~ 6,
                          C31 == "7 Definitely Would Use" ~ 7),
         c32n = case_when(C32 == "1 Definitely Would Not Use" ~1,
                          C32 == "2" ~ 2,
                          C32 == "3" ~ 3,
                          C32 == "4" ~ 4,
                          C32 == "5" ~ 5,
                          C32 == "6" ~ 6,
                          C32 == "7 Definitely Would Use" ~ 7),
         c41n = case_when(C41 == "1 Definitely Would Not Use" ~1,
                          C41 == "2" ~ 2,
                          C41 == "3" ~ 3,
                          C41 == "4" ~ 4,
                          C41 == "5" ~ 5,
                          C41 == "6" ~ 6,
                          C41 == "7 Definitely Would Use" ~ 7),
         c42n = case_when(C42 == "1 Definitely Would Not Use" ~1,
                          C42 == "2" ~ 2,
                          C42 == "3" ~ 3,
                          C42 == "4" ~ 4,
                          C42 == "5" ~ 5,
                          C42 == "6" ~ 6,
                          C42 == "7 Definitely Would Use" ~ 7),
         c51n = case_when(C51 == "1 Definitely Would Not Use" ~1,
                          C51 == "2" ~ 2,
                          C51 == "3" ~ 3,
                          C51 == "4" ~ 4,
                          C51 == "5" ~ 5,
                          C51 == "6" ~ 6,
                          C51 == "7 Definitely Would Use" ~ 7),
         c52n = case_when(C52 == "1 Definitely Would Not Use" ~1,
                          C52 == "2" ~ 2,
                          C52 == "3" ~ 3,
                          C52 == "4" ~ 4,
                          C52 == "5" ~ 5,
                          C52 == "6" ~ 6,
                          C52 == "7 Definitely Would Use" ~ 7)) %>%
  mutate(c11c = ifelse(c11n > 4, 1, 0),
         c12c = ifelse(c12n > 4, 1, 0),
         c21c = ifelse(c21n > 4, 1, 0),
         c22c = ifelse(c22n > 4, 1, 0),
         c31c = ifelse(c31n > 4, 1, 0),
         c32c = ifelse(c32n > 4, 1, 0),
         c41c = ifelse(c41n > 4, 1, 0),
         c42c = ifelse(c42n > 4, 1, 0),
         c51c = ifelse(c51n > 4, 1, 0),
         c52c = ifelse(c52n > 4, 1, 0))

conjoint3 <- conjoint3 %>%
  mutate(c1c1 = ifelse(C1_1 == "Choice 1", 1, 0),
         c1c2 = ifelse(C1_1 == "Choice 2", 1, 0),
         c2c1 = ifelse(C2_1 == "Choice 1", 1, 0),
         c2c2 = ifelse(C2_1 == "Choice 2", 1, 0),
         c3c1 = ifelse(C3_1 == "Choice 1", 1, 0),
         c3c2 = ifelse(C3_1 == "Choice 2", 1, 0),
         c4c1 = ifelse(C4_1 == "Choice 1", 1, 0),
         c4c2 = ifelse(C4_1 == "Choice 2", 1, 0),
         c5c1 = ifelse(C5_1 == "Choice 1", 1, 0),
         c5c2 = ifelse(C5_1 == "Choice 2", 1, 0)) %>%
  mutate(c11n = case_when(C11 == "1 Definitely Would Not Use" ~1,
                          C11 == "2" ~ 2,
                          C11 == "3" ~ 3,
                          C11 == "4" ~ 4,
                          C11 == "5" ~ 5,
                          C11 == "6" ~ 6,
                          C11 == "7 Definitely Would Use" ~ 7),
         c12n = case_when(C12 == "1 Definitely Would Not Use" ~1,
                          C12 == "2" ~ 2,
                          C12 == "3" ~ 3,
                          C12 == "4" ~ 4,
                          C12 == "5" ~ 5,
                          C12 == "6" ~ 6,
                          C12 == "7 Definitely Would Use" ~ 7),
         c21n = case_when(C21 == "1 Definitely Would Not Use" ~1,
                          C21 == "2" ~ 2,
                          C21 == "3" ~ 3,
                          C21 == "4" ~ 4,
                          C21 == "5" ~ 5,
                          C21 == "6" ~ 6,
                          C21 == "7 Definitely Would Use" ~ 7),
         c22n = case_when(C22 == "1 Definitely Would Not Use" ~1,
                          C22 == "2" ~ 2,
                          C22 == "3" ~ 3,
                          C22 == "4" ~ 4,
                          C22 == "5" ~ 5,
                          C22 == "6" ~ 6,
                          C22 == "7 Definitely Would Use" ~ 7),
         c31n = case_when(C31 == "1 Definitely Would Not Use" ~1,
                          C31 == "2" ~ 2,
                          C31 == "3" ~ 3,
                          C31 == "4" ~ 4,
                          C31 == "5" ~ 5,
                          C31 == "6" ~ 6,
                          C31 == "7 Definitely Would Use" ~ 7),
         c32n = case_when(C32 == "1 Definitely Would Not Use" ~1,
                          C32 == "2" ~ 2,
                          C32 == "3" ~ 3,
                          C32 == "4" ~ 4,
                          C32 == "5" ~ 5,
                          C32 == "6" ~ 6,
                          C32 == "7 Definitely Would Use" ~ 7),
         c41n = case_when(C41 == "1 Definitely Would Not Use" ~1,
                          C41 == "2" ~ 2,
                          C41 == "3" ~ 3,
                          C41 == "4" ~ 4,
                          C41 == "5" ~ 5,
                          C41 == "6" ~ 6,
                          C41 == "7 Definitely Would Use" ~ 7),
         c42n = case_when(C42 == "1 Definitely Would Not Use" ~1,
                          C42 == "2" ~ 2,
                          C42 == "3" ~ 3,
                          C42 == "4" ~ 4,
                          C42 == "5" ~ 5,
                          C42 == "6" ~ 6,
                          C42 == "7 Definitely Would Use" ~ 7),
         c51n = case_when(C51 == "1 Definitely Would Not Use" ~1,
                          C51 == "2" ~ 2,
                          C51 == "3" ~ 3,
                          C51 == "4" ~ 4,
                          C51 == "5" ~ 5,
                          C51 == "6" ~ 6,
                          C51 == "7 Definitely Would Use" ~ 7),
         c52n = case_when(C52 == "1 Definitely Would Not Use" ~1,
                          C52 == "2" ~ 2,
                          C52 == "3" ~ 3,
                          C52 == "4" ~ 4,
                          C52 == "5" ~ 5,
                          C52 == "6" ~ 6,
                          C52 == "7 Definitely Would Use" ~ 7)) %>%
  mutate(c11c = ifelse(c11n > 4, 1, 0),
         c12c = ifelse(c12n > 4, 1, 0),
         c21c = ifelse(c21n > 4, 1, 0),
         c22c = ifelse(c22n > 4, 1, 0),
         c31c = ifelse(c31n > 4, 1, 0),
         c32c = ifelse(c32n > 4, 1, 0),
         c41c = ifelse(c41n > 4, 1, 0),
         c42c = ifelse(c42n > 4, 1, 0),
         c51c = ifelse(c51n > 4, 1, 0),
         c52c = ifelse(c52n > 4, 1, 0))


#### Recode the characteristics of the algorithms for each choice.
defendant1 <- conjoint %>%
  select(ResponseId, c1c1, c1c2, c11c, c12c, starts_with("F-1")) %>%
  mutate(nfactors11 = case_when(`F-1-1` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-1`,
                                `F-1-2` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-2`,
                                `F-1-3` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-3`,
                                `F-1-4` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-4`,
                                `F-1-5` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-5`,
                                `F-1-6` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-6`,
                                `F-1-7` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-7`,
                                `F-1-8` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-8`),
         location11 = case_when(`F-1-1` == "Location from which data to create the algorithm was collected."~`F-1-1-1`,
                                `F-1-2` == "Location from which data to create the algorithm was collected."~`F-1-1-2`,
                                `F-1-3` == "Location from which data to create the algorithm was collected."~`F-1-1-3`,
                                `F-1-4` == "Location from which data to create the algorithm was collected."~`F-1-1-4`,
                                `F-1-5` == "Location from which data to create the algorithm was collected."~`F-1-1-5`,
                                `F-1-6` == "Location from which data to create the algorithm was collected."~`F-1-1-6`,
                                `F-1-7` == "Location from which data to create the algorithm was collected."~`F-1-1-7`,
                                `F-1-8` == "Location from which data to create the algorithm was collected."~`F-1-1-8`),
         moe11 = case_when(`F-1-1` == "Estimated margin of error of probability estimates."~`F-1-1-1`,
                           `F-1-2` == "Estimated margin of error of probability estimates."~`F-1-1-2`,
                           `F-1-3` == "Estimated margin of error of probability estimates."~`F-1-1-3`,
                           `F-1-4` == "Estimated margin of error of probability estimates."~`F-1-1-4`,
                           `F-1-5` == "Estimated margin of error of probability estimates."~`F-1-1-5`,
                           `F-1-6` == "Estimated margin of error of probability estimates."~`F-1-1-6`,
                           `F-1-7` == "Estimated margin of error of probability estimates."~`F-1-1-7`,
                           `F-1-8` == "Estimated margin of error of probability estimates."~`F-1-1-8`),
         weights11 = case_when(`F-1-1` == "Amount of weight given to different factors."~`F-1-1-1`,
                               `F-1-2` == "Amount of weight given to different factors."~`F-1-1-2`,
                               `F-1-3` == "Amount of weight given to different factors."~`F-1-1-3`,
                               `F-1-4` == "Amount of weight given to different factors."~`F-1-1-4`,
                               `F-1-5` == "Amount of weight given to different factors."~`F-1-1-5`,
                               `F-1-6` == "Amount of weight given to different factors."~`F-1-1-6`,
                               `F-1-7` == "Amount of weight given to different factors."~`F-1-1-7`,
                               `F-1-8` == "Amount of weight given to different factors."~`F-1-1-8`),
         accuracy11 = case_when(`F-1-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-1`,
                                `F-1-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-2`,
                                `F-1-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-3`,
                                `F-1-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-4`,
                                `F-1-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-5`,
                                `F-1-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-6`,
                                `F-1-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-7`,
                                `F-1-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-8`),
         human11 = case_when(`F-1-1` == "Human involvement in final estimate (if any)."~`F-1-1-1`,
                             `F-1-2` == "Human involvement in final estimate (if any)."~`F-1-1-2`,
                             `F-1-3` == "Human involvement in final estimate (if any)."~`F-1-1-3`,
                             `F-1-4` == "Human involvement in final estimate (if any)."~`F-1-1-4`,
                             `F-1-5` == "Human involvement in final estimate (if any)."~`F-1-1-5`,
                             `F-1-6` == "Human involvement in final estimate (if any)."~`F-1-1-6`,
                             `F-1-7` == "Human involvement in final estimate (if any)."~`F-1-1-7`,
                             `F-1-8` == "Human involvement in final estimate (if any)."~`F-1-1-8`),
         datasize11 = case_when(`F-1-1` == "Number of cases used to create the algorithm."~`F-1-1-1`,
                                `F-1-2` == "Number of cases used to create the algorithm."~`F-1-1-2`,
                                `F-1-3` == "Number of cases used to create the algorithm."~`F-1-1-3`,
                                `F-1-4` == "Number of cases used to create the algorithm."~`F-1-1-4`,
                                `F-1-5` == "Number of cases used to create the algorithm."~`F-1-1-5`,
                                `F-1-6` == "Number of cases used to create the algorithm."~`F-1-1-6`,
                                `F-1-7` == "Number of cases used to create the algorithm."~`F-1-1-7`,
                                `F-1-8` == "Number of cases used to create the algorithm."~`F-1-1-8`),
         developer11 = case_when(`F-1-1` == "Who developed the algorithm."~`F-1-1-1`,
                                 `F-1-2` == "Who developed the algorithm."~`F-1-1-2`,
                                 `F-1-3` == "Who developed the algorithm."~`F-1-1-3`,
                                 `F-1-4` == "Who developed the algorithm."~`F-1-1-4`,
                                 `F-1-5` == "Who developed the algorithm."~`F-1-1-5`,
                                 `F-1-6` == "Who developed the algorithm."~`F-1-1-6`,
                                 `F-1-7` == "Who developed the algorithm."~`F-1-1-7`,
                                 `F-1-8` == "Who developed the algorithm."~`F-1-1-8`),
         nfactors12 = case_when(`F-1-1` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-1`,
                                `F-1-2` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-2`,
                                `F-1-3` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-3`,
                                `F-1-4` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-4`,
                                `F-1-5` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-5`,
                                `F-1-6` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-6`,
                                `F-1-7` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-7`,
                                `F-1-8` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-8`),
         location12 = case_when(`F-1-1` == "Location from which data to create the algorithm was collected."~`F-1-2-1`,
                                `F-1-2` == "Location from which data to create the algorithm was collected."~`F-1-2-2`,
                                `F-1-3` == "Location from which data to create the algorithm was collected."~`F-1-2-3`,
                                `F-1-4` == "Location from which data to create the algorithm was collected."~`F-1-2-4`,
                                `F-1-5` == "Location from which data to create the algorithm was collected."~`F-1-2-5`,
                                `F-1-6` == "Location from which data to create the algorithm was collected."~`F-1-2-6`,
                                `F-1-7` == "Location from which data to create the algorithm was collected."~`F-1-2-7`,
                                `F-1-8` == "Location from which data to create the algorithm was collected."~`F-1-2-8`),
         moe12 = case_when(`F-1-1` == "Estimated margin of error of probability estimates."~`F-1-2-1`,
                           `F-1-2` == "Estimated margin of error of probability estimates."~`F-1-2-2`,
                           `F-1-3` == "Estimated margin of error of probability estimates."~`F-1-2-3`,
                           `F-1-4` == "Estimated margin of error of probability estimates."~`F-1-2-4`,
                           `F-1-5` == "Estimated margin of error of probability estimates."~`F-1-2-5`,
                           `F-1-6` == "Estimated margin of error of probability estimates."~`F-1-2-6`,
                           `F-1-7` == "Estimated margin of error of probability estimates."~`F-1-2-7`,
                           `F-1-8` == "Estimated margin of error of probability estimates."~`F-1-2-8`),
         weights12 = case_when(`F-1-1` == "Amount of weight given to different factors."~`F-1-2-1`,
                               `F-1-2` == "Amount of weight given to different factors."~`F-1-2-2`,
                               `F-1-3` == "Amount of weight given to different factors."~`F-1-2-3`,
                               `F-1-4` == "Amount of weight given to different factors."~`F-1-2-4`,
                               `F-1-5` == "Amount of weight given to different factors."~`F-1-2-5`,
                               `F-1-6` == "Amount of weight given to different factors."~`F-1-2-6`,
                               `F-1-7` == "Amount of weight given to different factors."~`F-1-2-7`,
                               `F-1-8` == "Amount of weight given to different factors."~`F-1-2-8`),
         accuracy12 = case_when(`F-1-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-1`,
                                `F-1-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-2`,
                                `F-1-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-3`,
                                `F-1-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-4`,
                                `F-1-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-5`,
                                `F-1-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-6`,
                                `F-1-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-7`,
                                `F-1-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-8`),
         human12 = case_when(`F-1-1` == "Human involvement in final estimate (if any)."~`F-1-2-1`,
                             `F-1-2` == "Human involvement in final estimate (if any)."~`F-1-2-2`,
                             `F-1-3` == "Human involvement in final estimate (if any)."~`F-1-2-3`,
                             `F-1-4` == "Human involvement in final estimate (if any)."~`F-1-2-4`,
                             `F-1-5` == "Human involvement in final estimate (if any)."~`F-1-2-5`,
                             `F-1-6` == "Human involvement in final estimate (if any)."~`F-1-2-6`,
                             `F-1-7` == "Human involvement in final estimate (if any)."~`F-1-2-7`,
                             `F-1-8` == "Human involvement in final estimate (if any)."~`F-1-2-8`),
         datasize12 = case_when(`F-1-1` == "Number of cases used to create the algorithm."~`F-1-2-1`,
                                `F-1-2` == "Number of cases used to create the algorithm."~`F-1-2-2`,
                                `F-1-3` == "Number of cases used to create the algorithm."~`F-1-2-3`,
                                `F-1-4` == "Number of cases used to create the algorithm."~`F-1-2-4`,
                                `F-1-5` == "Number of cases used to create the algorithm."~`F-1-2-5`,
                                `F-1-6` == "Number of cases used to create the algorithm."~`F-1-2-6`,
                                `F-1-7` == "Number of cases used to create the algorithm."~`F-1-2-7`,
                                `F-1-8` == "Number of cases used to create the algorithm."~`F-1-2-8`),
         developer12 = case_when(`F-1-1` == "Who developed the algorithm."~`F-1-2-1`,
                                 `F-1-2` == "Who developed the algorithm."~`F-1-2-2`,
                                 `F-1-3` == "Who developed the algorithm."~`F-1-2-3`,
                                 `F-1-4` == "Who developed the algorithm."~`F-1-2-4`,
                                 `F-1-5` == "Who developed the algorithm."~`F-1-2-5`,
                                 `F-1-6` == "Who developed the algorithm."~`F-1-2-6`,
                                 `F-1-7` == "Who developed the algorithm."~`F-1-2-7`,
                                 `F-1-8` == "Who developed the algorithm."~`F-1-2-8`)) %>%
  select(ResponseId, c1c1, c1c2, c11c, c12c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c1c1:c1c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c1c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c1c1", location11, location12)),
         moe= (ifelse(choiceNum == "c1c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c1c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c1c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c1c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c1c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c1c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c1c1", c11c, c12c)),
         defendant = 1,
         sample = "MTurk") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant2 <- conjoint %>%
  select(ResponseId, c2c1, c2c2, c21c, c22c, starts_with("F-2")) %>%
  mutate(nfactors11 = case_when(`F-2-1` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-1`,
                                `F-2-2` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-2`,
                                `F-2-3` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-3`,
                                `F-2-4` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-4`,
                                `F-2-5` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-5`,
                                `F-2-6` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-6`,
                                `F-2-7` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-7`,
                                `F-2-8` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-8`),
         location11 = case_when(`F-2-1` == "Location from which data to create the algorithm was collected."~`F-2-1-1`,
                                `F-2-2` == "Location from which data to create the algorithm was collected."~`F-2-1-2`,
                                `F-2-3` == "Location from which data to create the algorithm was collected."~`F-2-1-3`,
                                `F-2-4` == "Location from which data to create the algorithm was collected."~`F-2-1-4`,
                                `F-2-5` == "Location from which data to create the algorithm was collected."~`F-2-1-5`,
                                `F-2-6` == "Location from which data to create the algorithm was collected."~`F-2-1-6`,
                                `F-2-7` == "Location from which data to create the algorithm was collected."~`F-2-1-7`,
                                `F-2-8` == "Location from which data to create the algorithm was collected."~`F-2-1-8`),
         moe11 = case_when(`F-2-1` == "Estimated margin of error of probability estimates."~`F-2-1-1`,
                           `F-2-2` == "Estimated margin of error of probability estimates."~`F-2-1-2`,
                           `F-2-3` == "Estimated margin of error of probability estimates."~`F-2-1-3`,
                           `F-2-4` == "Estimated margin of error of probability estimates."~`F-2-1-4`,
                           `F-2-5` == "Estimated margin of error of probability estimates."~`F-2-1-5`,
                           `F-2-6` == "Estimated margin of error of probability estimates."~`F-2-1-6`,
                           `F-2-7` == "Estimated margin of error of probability estimates."~`F-2-1-7`,
                           `F-2-8` == "Estimated margin of error of probability estimates."~`F-2-1-8`),
         weights11 = case_when(`F-2-1` == "Amount of weight given to different factors."~`F-2-1-1`,
                               `F-2-2` == "Amount of weight given to different factors."~`F-2-1-2`,
                               `F-2-3` == "Amount of weight given to different factors."~`F-2-1-3`,
                               `F-2-4` == "Amount of weight given to different factors."~`F-2-1-4`,
                               `F-2-5` == "Amount of weight given to different factors."~`F-2-1-5`,
                               `F-2-6` == "Amount of weight given to different factors."~`F-2-1-6`,
                               `F-2-7` == "Amount of weight given to different factors."~`F-2-1-7`,
                               `F-2-8` == "Amount of weight given to different factors."~`F-2-1-8`),
         accuracy11 = case_when(`F-2-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-1`,
                                `F-2-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-2`,
                                `F-2-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-3`,
                                `F-2-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-4`,
                                `F-2-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-5`,
                                `F-2-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-6`,
                                `F-2-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-7`,
                                `F-2-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-8`),
         human11 = case_when(`F-2-1` == "Human involvement in final estimate (if any)."~`F-2-1-1`,
                             `F-2-2` == "Human involvement in final estimate (if any)."~`F-2-1-2`,
                             `F-2-3` == "Human involvement in final estimate (if any)."~`F-2-1-3`,
                             `F-2-4` == "Human involvement in final estimate (if any)."~`F-2-1-4`,
                             `F-2-5` == "Human involvement in final estimate (if any)."~`F-2-1-5`,
                             `F-2-6` == "Human involvement in final estimate (if any)."~`F-2-1-6`,
                             `F-2-7` == "Human involvement in final estimate (if any)."~`F-2-1-7`,
                             `F-2-8` == "Human involvement in final estimate (if any)."~`F-2-1-8`),
         datasize11 = case_when(`F-2-1` == "Number of cases used to create the algorithm."~`F-2-1-1`,
                                `F-2-2` == "Number of cases used to create the algorithm."~`F-2-1-2`,
                                `F-2-3` == "Number of cases used to create the algorithm."~`F-2-1-3`,
                                `F-2-4` == "Number of cases used to create the algorithm."~`F-2-1-4`,
                                `F-2-5` == "Number of cases used to create the algorithm."~`F-2-1-5`,
                                `F-2-6` == "Number of cases used to create the algorithm."~`F-2-1-6`,
                                `F-2-7` == "Number of cases used to create the algorithm."~`F-2-1-7`,
                                `F-2-8` == "Number of cases used to create the algorithm."~`F-2-1-8`),
         developer11 = case_when(`F-2-1` == "Who developed the algorithm."~`F-2-1-1`,
                                 `F-2-2` == "Who developed the algorithm."~`F-2-1-2`,
                                 `F-2-3` == "Who developed the algorithm."~`F-2-1-3`,
                                 `F-2-4` == "Who developed the algorithm."~`F-2-1-4`,
                                 `F-2-5` == "Who developed the algorithm."~`F-2-1-5`,
                                 `F-2-6` == "Who developed the algorithm."~`F-2-1-6`,
                                 `F-2-7` == "Who developed the algorithm."~`F-2-1-7`,
                                 `F-2-8` == "Who developed the algorithm."~`F-2-1-8`),
         nfactors12 = case_when(`F-2-1` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-1`,
                                `F-2-2` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-2`,
                                `F-2-3` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-3`,
                                `F-2-4` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-4`,
                                `F-2-5` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-5`,
                                `F-2-6` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-6`,
                                `F-2-7` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-7`,
                                `F-2-8` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-8`),
         location12 = case_when(`F-2-1` == "Location from which data to create the algorithm was collected."~`F-2-2-1`,
                                `F-2-2` == "Location from which data to create the algorithm was collected."~`F-2-2-2`,
                                `F-2-3` == "Location from which data to create the algorithm was collected."~`F-2-2-3`,
                                `F-2-4` == "Location from which data to create the algorithm was collected."~`F-2-2-4`,
                                `F-2-5` == "Location from which data to create the algorithm was collected."~`F-2-2-5`,
                                `F-2-6` == "Location from which data to create the algorithm was collected."~`F-2-2-6`,
                                `F-2-7` == "Location from which data to create the algorithm was collected."~`F-2-2-7`,
                                `F-2-8` == "Location from which data to create the algorithm was collected."~`F-2-2-8`),
         moe12 = case_when(`F-2-1` == "Estimated margin of error of probability estimates."~`F-2-2-1`,
                           `F-2-2` == "Estimated margin of error of probability estimates."~`F-2-2-2`,
                           `F-2-3` == "Estimated margin of error of probability estimates."~`F-2-2-3`,
                           `F-2-4` == "Estimated margin of error of probability estimates."~`F-2-2-4`,
                           `F-2-5` == "Estimated margin of error of probability estimates."~`F-2-2-5`,
                           `F-2-6` == "Estimated margin of error of probability estimates."~`F-2-2-6`,
                           `F-2-7` == "Estimated margin of error of probability estimates."~`F-2-2-7`,
                           `F-2-8` == "Estimated margin of error of probability estimates."~`F-2-2-8`),
         weights12 = case_when(`F-2-1` == "Amount of weight given to different factors."~`F-2-2-1`,
                               `F-2-2` == "Amount of weight given to different factors."~`F-2-2-2`,
                               `F-2-3` == "Amount of weight given to different factors."~`F-2-2-3`,
                               `F-2-4` == "Amount of weight given to different factors."~`F-2-2-4`,
                               `F-2-5` == "Amount of weight given to different factors."~`F-2-2-5`,
                               `F-2-6` == "Amount of weight given to different factors."~`F-2-2-6`,
                               `F-2-7` == "Amount of weight given to different factors."~`F-2-2-7`,
                               `F-2-8` == "Amount of weight given to different factors."~`F-2-2-8`),
         accuracy12 = case_when(`F-2-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-1`,
                                `F-2-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-2`,
                                `F-2-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-3`,
                                `F-2-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-4`,
                                `F-2-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-5`,
                                `F-2-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-6`,
                                `F-2-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-7`,
                                `F-2-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-8`),
         human12 = case_when(`F-2-1` == "Human involvement in final estimate (if any)."~`F-2-2-1`,
                             `F-2-2` == "Human involvement in final estimate (if any)."~`F-2-2-2`,
                             `F-2-3` == "Human involvement in final estimate (if any)."~`F-2-2-3`,
                             `F-2-4` == "Human involvement in final estimate (if any)."~`F-2-2-4`,
                             `F-2-5` == "Human involvement in final estimate (if any)."~`F-2-2-5`,
                             `F-2-6` == "Human involvement in final estimate (if any)."~`F-2-2-6`,
                             `F-2-7` == "Human involvement in final estimate (if any)."~`F-2-2-7`,
                             `F-2-8` == "Human involvement in final estimate (if any)."~`F-2-2-8`),
         datasize12 = case_when(`F-2-1` == "Number of cases used to create the algorithm."~`F-2-2-1`,
                                `F-2-2` == "Number of cases used to create the algorithm."~`F-2-2-2`,
                                `F-2-3` == "Number of cases used to create the algorithm."~`F-2-2-3`,
                                `F-2-4` == "Number of cases used to create the algorithm."~`F-2-2-4`,
                                `F-2-5` == "Number of cases used to create the algorithm."~`F-2-2-5`,
                                `F-2-6` == "Number of cases used to create the algorithm."~`F-2-2-6`,
                                `F-2-7` == "Number of cases used to create the algorithm."~`F-2-2-7`,
                                `F-2-8` == "Number of cases used to create the algorithm."~`F-2-2-8`),
         developer12 = case_when(`F-2-1` == "Who developed the algorithm."~`F-2-2-1`,
                                 `F-2-2` == "Who developed the algorithm."~`F-2-2-2`,
                                 `F-2-3` == "Who developed the algorithm."~`F-2-2-3`,
                                 `F-2-4` == "Who developed the algorithm."~`F-2-2-4`,
                                 `F-2-5` == "Who developed the algorithm."~`F-2-2-5`,
                                 `F-2-6` == "Who developed the algorithm."~`F-2-2-6`,
                                 `F-2-7` == "Who developed the algorithm."~`F-2-2-7`,
                                 `F-2-8` == "Who developed the algorithm."~`F-2-2-8`)) %>%
  select(ResponseId, c2c1, c2c2, c21c, c22c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c2c1:c2c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c2c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c2c1", location11, location12)),
         moe= (ifelse(choiceNum == "c2c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c2c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c2c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c2c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c2c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c2c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c2c1", c21c, c22c)),
         defendant = 2,
         sample = "MTurk") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant3 <- conjoint %>%
  select(ResponseId, c3c1, c3c2, c31c, c32c, starts_with("F-3")) %>%
  mutate(nfactors11 = case_when(`F-3-1` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-1`,
                                `F-3-2` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-2`,
                                `F-3-3` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-3`,
                                `F-3-4` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-4`,
                                `F-3-5` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-5`,
                                `F-3-6` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-6`,
                                `F-3-7` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-7`,
                                `F-3-8` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-8`),
         location11 = case_when(`F-3-1` == "Location from which data to create the algorithm was collected."~`F-3-1-1`,
                                `F-3-2` == "Location from which data to create the algorithm was collected."~`F-3-1-2`,
                                `F-3-3` == "Location from which data to create the algorithm was collected."~`F-3-1-3`,
                                `F-3-4` == "Location from which data to create the algorithm was collected."~`F-3-1-4`,
                                `F-3-5` == "Location from which data to create the algorithm was collected."~`F-3-1-5`,
                                `F-3-6` == "Location from which data to create the algorithm was collected."~`F-3-1-6`,
                                `F-3-7` == "Location from which data to create the algorithm was collected."~`F-3-1-7`,
                                `F-3-8` == "Location from which data to create the algorithm was collected."~`F-3-1-8`),
         moe11 = case_when(`F-3-1` == "Estimated margin of error of probability estimates."~`F-3-1-1`,
                           `F-3-2` == "Estimated margin of error of probability estimates."~`F-3-1-2`,
                           `F-3-3` == "Estimated margin of error of probability estimates."~`F-3-1-3`,
                           `F-3-4` == "Estimated margin of error of probability estimates."~`F-3-1-4`,
                           `F-3-5` == "Estimated margin of error of probability estimates."~`F-3-1-5`,
                           `F-3-6` == "Estimated margin of error of probability estimates."~`F-3-1-6`,
                           `F-3-7` == "Estimated margin of error of probability estimates."~`F-3-1-7`,
                           `F-3-8` == "Estimated margin of error of probability estimates."~`F-3-1-8`),
         weights11 = case_when(`F-3-1` == "Amount of weight given to different factors."~`F-3-1-1`,
                               `F-3-2` == "Amount of weight given to different factors."~`F-3-1-2`,
                               `F-3-3` == "Amount of weight given to different factors."~`F-3-1-3`,
                               `F-3-4` == "Amount of weight given to different factors."~`F-3-1-4`,
                               `F-3-5` == "Amount of weight given to different factors."~`F-3-1-5`,
                               `F-3-6` == "Amount of weight given to different factors."~`F-3-1-6`,
                               `F-3-7` == "Amount of weight given to different factors."~`F-3-1-7`,
                               `F-3-8` == "Amount of weight given to different factors."~`F-3-1-8`),
         accuracy11 = case_when(`F-3-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-1`,
                                `F-3-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-2`,
                                `F-3-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-3`,
                                `F-3-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-4`,
                                `F-3-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-5`,
                                `F-3-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-6`,
                                `F-3-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-7`,
                                `F-3-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-8`),
         human11 = case_when(`F-3-1` == "Human involvement in final estimate (if any)."~`F-3-1-1`,
                             `F-3-2` == "Human involvement in final estimate (if any)."~`F-3-1-2`,
                             `F-3-3` == "Human involvement in final estimate (if any)."~`F-3-1-3`,
                             `F-3-4` == "Human involvement in final estimate (if any)."~`F-3-1-4`,
                             `F-3-5` == "Human involvement in final estimate (if any)."~`F-3-1-5`,
                             `F-3-6` == "Human involvement in final estimate (if any)."~`F-3-1-6`,
                             `F-3-7` == "Human involvement in final estimate (if any)."~`F-3-1-7`,
                             `F-3-8` == "Human involvement in final estimate (if any)."~`F-3-1-8`),
         datasize11 = case_when(`F-3-1` == "Number of cases used to create the algorithm."~`F-3-1-1`,
                                `F-3-2` == "Number of cases used to create the algorithm."~`F-3-1-2`,
                                `F-3-3` == "Number of cases used to create the algorithm."~`F-3-1-3`,
                                `F-3-4` == "Number of cases used to create the algorithm."~`F-3-1-4`,
                                `F-3-5` == "Number of cases used to create the algorithm."~`F-3-1-5`,
                                `F-3-6` == "Number of cases used to create the algorithm."~`F-3-1-6`,
                                `F-3-7` == "Number of cases used to create the algorithm."~`F-3-1-7`,
                                `F-3-8` == "Number of cases used to create the algorithm."~`F-3-1-8`),
         developer11 = case_when(`F-3-1` == "Who developed the algorithm."~`F-3-1-1`,
                                 `F-3-2` == "Who developed the algorithm."~`F-3-1-2`,
                                 `F-3-3` == "Who developed the algorithm."~`F-3-1-3`,
                                 `F-3-4` == "Who developed the algorithm."~`F-3-1-4`,
                                 `F-3-5` == "Who developed the algorithm."~`F-3-1-5`,
                                 `F-3-6` == "Who developed the algorithm."~`F-3-1-6`,
                                 `F-3-7` == "Who developed the algorithm."~`F-3-1-7`,
                                 `F-3-8` == "Who developed the algorithm."~`F-3-1-8`),
         nfactors12 = case_when(`F-3-1` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-1`,
                                `F-3-2` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-2`,
                                `F-3-3` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-3`,
                                `F-3-4` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-4`,
                                `F-3-5` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-5`,
                                `F-3-6` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-6`,
                                `F-3-7` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-7`,
                                `F-3-8` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-8`),
         location12 = case_when(`F-3-1` == "Location from which data to create the algorithm was collected."~`F-3-2-1`,
                                `F-3-2` == "Location from which data to create the algorithm was collected."~`F-3-2-2`,
                                `F-3-3` == "Location from which data to create the algorithm was collected."~`F-3-2-3`,
                                `F-3-4` == "Location from which data to create the algorithm was collected."~`F-3-2-4`,
                                `F-3-5` == "Location from which data to create the algorithm was collected."~`F-3-2-5`,
                                `F-3-6` == "Location from which data to create the algorithm was collected."~`F-3-2-6`,
                                `F-3-7` == "Location from which data to create the algorithm was collected."~`F-3-2-7`,
                                `F-3-8` == "Location from which data to create the algorithm was collected."~`F-3-2-8`),
         moe12 = case_when(`F-3-1` == "Estimated margin of error of probability estimates."~`F-3-2-1`,
                           `F-3-2` == "Estimated margin of error of probability estimates."~`F-3-2-2`,
                           `F-3-3` == "Estimated margin of error of probability estimates."~`F-3-2-3`,
                           `F-3-4` == "Estimated margin of error of probability estimates."~`F-3-2-4`,
                           `F-3-5` == "Estimated margin of error of probability estimates."~`F-3-2-5`,
                           `F-3-6` == "Estimated margin of error of probability estimates."~`F-3-2-6`,
                           `F-3-7` == "Estimated margin of error of probability estimates."~`F-3-2-7`,
                           `F-3-8` == "Estimated margin of error of probability estimates."~`F-3-2-8`),
         weights12 = case_when(`F-3-1` == "Amount of weight given to different factors."~`F-3-2-1`,
                               `F-3-2` == "Amount of weight given to different factors."~`F-3-2-2`,
                               `F-3-3` == "Amount of weight given to different factors."~`F-3-2-3`,
                               `F-3-4` == "Amount of weight given to different factors."~`F-3-2-4`,
                               `F-3-5` == "Amount of weight given to different factors."~`F-3-2-5`,
                               `F-3-6` == "Amount of weight given to different factors."~`F-3-2-6`,
                               `F-3-7` == "Amount of weight given to different factors."~`F-3-2-7`,
                               `F-3-8` == "Amount of weight given to different factors."~`F-3-2-8`),
         accuracy12 = case_when(`F-3-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-1`,
                                `F-3-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-2`,
                                `F-3-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-3`,
                                `F-3-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-4`,
                                `F-3-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-5`,
                                `F-3-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-6`,
                                `F-3-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-7`,
                                `F-3-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-8`),
         human12 = case_when(`F-3-1` == "Human involvement in final estimate (if any)."~`F-3-2-1`,
                             `F-3-2` == "Human involvement in final estimate (if any)."~`F-3-2-2`,
                             `F-3-3` == "Human involvement in final estimate (if any)."~`F-3-2-3`,
                             `F-3-4` == "Human involvement in final estimate (if any)."~`F-3-2-4`,
                             `F-3-5` == "Human involvement in final estimate (if any)."~`F-3-2-5`,
                             `F-3-6` == "Human involvement in final estimate (if any)."~`F-3-2-6`,
                             `F-3-7` == "Human involvement in final estimate (if any)."~`F-3-2-7`,
                             `F-3-8` == "Human involvement in final estimate (if any)."~`F-3-2-8`),
         datasize12 = case_when(`F-3-1` == "Number of cases used to create the algorithm."~`F-3-2-1`,
                                `F-3-2` == "Number of cases used to create the algorithm."~`F-3-2-2`,
                                `F-3-3` == "Number of cases used to create the algorithm."~`F-3-2-3`,
                                `F-3-4` == "Number of cases used to create the algorithm."~`F-3-2-4`,
                                `F-3-5` == "Number of cases used to create the algorithm."~`F-3-2-5`,
                                `F-3-6` == "Number of cases used to create the algorithm."~`F-3-2-6`,
                                `F-3-7` == "Number of cases used to create the algorithm."~`F-3-2-7`,
                                `F-3-8` == "Number of cases used to create the algorithm."~`F-3-2-8`),
         developer12 = case_when(`F-3-1` == "Who developed the algorithm."~`F-3-2-1`,
                                 `F-3-2` == "Who developed the algorithm."~`F-3-2-2`,
                                 `F-3-3` == "Who developed the algorithm."~`F-3-2-3`,
                                 `F-3-4` == "Who developed the algorithm."~`F-3-2-4`,
                                 `F-3-5` == "Who developed the algorithm."~`F-3-2-5`,
                                 `F-3-6` == "Who developed the algorithm."~`F-3-2-6`,
                                 `F-3-7` == "Who developed the algorithm."~`F-3-2-7`,
                                 `F-3-8` == "Who developed the algorithm."~`F-3-2-8`)) %>%
  select(ResponseId, c3c1, c3c2, c31c, c32c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c3c1:c3c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c3c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c3c1", location11, location12)),
         moe= (ifelse(choiceNum == "c3c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c3c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c3c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c3c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c3c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c3c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c3c1", c31c, c32c)),
         defendant = 3,
         sample = "MTurk") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant4 <- conjoint %>%
  select(ResponseId, c4c1, c4c2, c41c, c42c, starts_with("F-4")) %>%
  mutate(nfactors11 = case_when(`F-4-1` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-1`,
                                `F-4-2` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-2`,
                                `F-4-3` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-3`,
                                `F-4-4` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-4`,
                                `F-4-5` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-5`,
                                `F-4-6` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-6`,
                                `F-4-7` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-7`,
                                `F-4-8` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-8`),
         location11 = case_when(`F-4-1` == "Location from which data to create the algorithm was collected."~`F-4-1-1`,
                                `F-4-2` == "Location from which data to create the algorithm was collected."~`F-4-1-2`,
                                `F-4-3` == "Location from which data to create the algorithm was collected."~`F-4-1-3`,
                                `F-4-4` == "Location from which data to create the algorithm was collected."~`F-4-1-4`,
                                `F-4-5` == "Location from which data to create the algorithm was collected."~`F-4-1-5`,
                                `F-4-6` == "Location from which data to create the algorithm was collected."~`F-4-1-6`,
                                `F-4-7` == "Location from which data to create the algorithm was collected."~`F-4-1-7`,
                                `F-4-8` == "Location from which data to create the algorithm was collected."~`F-4-1-8`),
         moe11 = case_when(`F-4-1` == "Estimated margin of error of probability estimates."~`F-4-1-1`,
                           `F-4-2` == "Estimated margin of error of probability estimates."~`F-4-1-2`,
                           `F-4-3` == "Estimated margin of error of probability estimates."~`F-4-1-3`,
                           `F-4-4` == "Estimated margin of error of probability estimates."~`F-4-1-4`,
                           `F-4-5` == "Estimated margin of error of probability estimates."~`F-4-1-5`,
                           `F-4-6` == "Estimated margin of error of probability estimates."~`F-4-1-6`,
                           `F-4-7` == "Estimated margin of error of probability estimates."~`F-4-1-7`,
                           `F-4-8` == "Estimated margin of error of probability estimates."~`F-4-1-8`),
         weights11 = case_when(`F-4-1` == "Amount of weight given to different factors."~`F-4-1-1`,
                               `F-4-2` == "Amount of weight given to different factors."~`F-4-1-2`,
                               `F-4-3` == "Amount of weight given to different factors."~`F-4-1-3`,
                               `F-4-4` == "Amount of weight given to different factors."~`F-4-1-4`,
                               `F-4-5` == "Amount of weight given to different factors."~`F-4-1-5`,
                               `F-4-6` == "Amount of weight given to different factors."~`F-4-1-6`,
                               `F-4-7` == "Amount of weight given to different factors."~`F-4-1-7`,
                               `F-4-8` == "Amount of weight given to different factors."~`F-4-1-8`),
         accuracy11 = case_when(`F-4-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-1`,
                                `F-4-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-2`,
                                `F-4-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-3`,
                                `F-4-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-4`,
                                `F-4-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-5`,
                                `F-4-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-6`,
                                `F-4-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-7`,
                                `F-4-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-8`),
         human11 = case_when(`F-4-1` == "Human involvement in final estimate (if any)."~`F-4-1-1`,
                             `F-4-2` == "Human involvement in final estimate (if any)."~`F-4-1-2`,
                             `F-4-3` == "Human involvement in final estimate (if any)."~`F-4-1-3`,
                             `F-4-4` == "Human involvement in final estimate (if any)."~`F-4-1-4`,
                             `F-4-5` == "Human involvement in final estimate (if any)."~`F-4-1-5`,
                             `F-4-6` == "Human involvement in final estimate (if any)."~`F-4-1-6`,
                             `F-4-7` == "Human involvement in final estimate (if any)."~`F-4-1-7`,
                             `F-4-8` == "Human involvement in final estimate (if any)."~`F-4-1-8`),
         datasize11 = case_when(`F-4-1` == "Number of cases used to create the algorithm."~`F-4-1-1`,
                                `F-4-2` == "Number of cases used to create the algorithm."~`F-4-1-2`,
                                `F-4-3` == "Number of cases used to create the algorithm."~`F-4-1-3`,
                                `F-4-4` == "Number of cases used to create the algorithm."~`F-4-1-4`,
                                `F-4-5` == "Number of cases used to create the algorithm."~`F-4-1-5`,
                                `F-4-6` == "Number of cases used to create the algorithm."~`F-4-1-6`,
                                `F-4-7` == "Number of cases used to create the algorithm."~`F-4-1-7`,
                                `F-4-8` == "Number of cases used to create the algorithm."~`F-4-1-8`),
         developer11 = case_when(`F-4-1` == "Who developed the algorithm."~`F-4-1-1`,
                                 `F-4-2` == "Who developed the algorithm."~`F-4-1-2`,
                                 `F-4-3` == "Who developed the algorithm."~`F-4-1-3`,
                                 `F-4-4` == "Who developed the algorithm."~`F-4-1-4`,
                                 `F-4-5` == "Who developed the algorithm."~`F-4-1-5`,
                                 `F-4-6` == "Who developed the algorithm."~`F-4-1-6`,
                                 `F-4-7` == "Who developed the algorithm."~`F-4-1-7`,
                                 `F-4-8` == "Who developed the algorithm."~`F-4-1-8`),
         nfactors12 = case_when(`F-4-1` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-1`,
                                `F-4-2` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-2`,
                                `F-4-3` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-3`,
                                `F-4-4` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-4`,
                                `F-4-5` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-5`,
                                `F-4-6` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-6`,
                                `F-4-7` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-7`,
                                `F-4-8` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-8`),
         location12 = case_when(`F-4-1` == "Location from which data to create the algorithm was collected."~`F-4-2-1`,
                                `F-4-2` == "Location from which data to create the algorithm was collected."~`F-4-2-2`,
                                `F-4-3` == "Location from which data to create the algorithm was collected."~`F-4-2-3`,
                                `F-4-4` == "Location from which data to create the algorithm was collected."~`F-4-2-4`,
                                `F-4-5` == "Location from which data to create the algorithm was collected."~`F-4-2-5`,
                                `F-4-6` == "Location from which data to create the algorithm was collected."~`F-4-2-6`,
                                `F-4-7` == "Location from which data to create the algorithm was collected."~`F-4-2-7`,
                                `F-4-8` == "Location from which data to create the algorithm was collected."~`F-4-2-8`),
         moe12 = case_when(`F-4-1` == "Estimated margin of error of probability estimates."~`F-4-2-1`,
                           `F-4-2` == "Estimated margin of error of probability estimates."~`F-4-2-2`,
                           `F-4-3` == "Estimated margin of error of probability estimates."~`F-4-2-3`,
                           `F-4-4` == "Estimated margin of error of probability estimates."~`F-4-2-4`,
                           `F-4-5` == "Estimated margin of error of probability estimates."~`F-4-2-5`,
                           `F-4-6` == "Estimated margin of error of probability estimates."~`F-4-2-6`,
                           `F-4-7` == "Estimated margin of error of probability estimates."~`F-4-2-7`,
                           `F-4-8` == "Estimated margin of error of probability estimates."~`F-4-2-8`),
         weights12 = case_when(`F-4-1` == "Amount of weight given to different factors."~`F-4-2-1`,
                               `F-4-2` == "Amount of weight given to different factors."~`F-4-2-2`,
                               `F-4-3` == "Amount of weight given to different factors."~`F-4-2-3`,
                               `F-4-4` == "Amount of weight given to different factors."~`F-4-2-4`,
                               `F-4-5` == "Amount of weight given to different factors."~`F-4-2-5`,
                               `F-4-6` == "Amount of weight given to different factors."~`F-4-2-6`,
                               `F-4-7` == "Amount of weight given to different factors."~`F-4-2-7`,
                               `F-4-8` == "Amount of weight given to different factors."~`F-4-2-8`),
         accuracy12 = case_when(`F-4-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-1`,
                                `F-4-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-2`,
                                `F-4-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-3`,
                                `F-4-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-4`,
                                `F-4-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-5`,
                                `F-4-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-6`,
                                `F-4-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-7`,
                                `F-4-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-8`),
         human12 = case_when(`F-4-1` == "Human involvement in final estimate (if any)."~`F-4-2-1`,
                             `F-4-2` == "Human involvement in final estimate (if any)."~`F-4-2-2`,
                             `F-4-3` == "Human involvement in final estimate (if any)."~`F-4-2-3`,
                             `F-4-4` == "Human involvement in final estimate (if any)."~`F-4-2-4`,
                             `F-4-5` == "Human involvement in final estimate (if any)."~`F-4-2-5`,
                             `F-4-6` == "Human involvement in final estimate (if any)."~`F-4-2-6`,
                             `F-4-7` == "Human involvement in final estimate (if any)."~`F-4-2-7`,
                             `F-4-8` == "Human involvement in final estimate (if any)."~`F-4-2-8`),
         datasize12 = case_when(`F-4-1` == "Number of cases used to create the algorithm."~`F-4-2-1`,
                                `F-4-2` == "Number of cases used to create the algorithm."~`F-4-2-2`,
                                `F-4-3` == "Number of cases used to create the algorithm."~`F-4-2-3`,
                                `F-4-4` == "Number of cases used to create the algorithm."~`F-4-2-4`,
                                `F-4-5` == "Number of cases used to create the algorithm."~`F-4-2-5`,
                                `F-4-6` == "Number of cases used to create the algorithm."~`F-4-2-6`,
                                `F-4-7` == "Number of cases used to create the algorithm."~`F-4-2-7`,
                                `F-4-8` == "Number of cases used to create the algorithm."~`F-4-2-8`),
         developer12 = case_when(`F-4-1` == "Who developed the algorithm."~`F-4-2-1`,
                                 `F-4-2` == "Who developed the algorithm."~`F-4-2-2`,
                                 `F-4-3` == "Who developed the algorithm."~`F-4-2-3`,
                                 `F-4-4` == "Who developed the algorithm."~`F-4-2-4`,
                                 `F-4-5` == "Who developed the algorithm."~`F-4-2-5`,
                                 `F-4-6` == "Who developed the algorithm."~`F-4-2-6`,
                                 `F-4-7` == "Who developed the algorithm."~`F-4-2-7`,
                                 `F-4-8` == "Who developed the algorithm."~`F-4-2-8`)) %>%
  select(ResponseId, c4c1, c4c2, c41c, c42c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c4c1:c4c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c4c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c4c1", location11, location12)),
         moe= (ifelse(choiceNum == "c4c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c4c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c4c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c4c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c4c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c4c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c4c1", c41c, c42c)),
         defendant = 4,
         sample = "MTurk") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant5 <- conjoint %>%
  select(ResponseId, c5c1, c5c2, c51c, c52c, starts_with("F-5")) %>%
  mutate(nfactors11 = case_when(`F-5-1` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-1`,
                                `F-5-2` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-2`,
                                `F-5-3` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-3`,
                                `F-5-4` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-4`,
                                `F-5-5` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-5`,
                                `F-5-6` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-6`,
                                `F-5-7` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-7`,
                                `F-5-8` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-8`),
         location11 = case_when(`F-5-1` == "Location from which data to create the algorithm was collected."~`F-5-1-1`,
                                `F-5-2` == "Location from which data to create the algorithm was collected."~`F-5-1-2`,
                                `F-5-3` == "Location from which data to create the algorithm was collected."~`F-5-1-3`,
                                `F-5-4` == "Location from which data to create the algorithm was collected."~`F-5-1-4`,
                                `F-5-5` == "Location from which data to create the algorithm was collected."~`F-5-1-5`,
                                `F-5-6` == "Location from which data to create the algorithm was collected."~`F-5-1-6`,
                                `F-5-7` == "Location from which data to create the algorithm was collected."~`F-5-1-7`,
                                `F-5-8` == "Location from which data to create the algorithm was collected."~`F-5-1-8`),
         moe11 = case_when(`F-5-1` == "Estimated margin of error of probability estimates."~`F-5-1-1`,
                           `F-5-2` == "Estimated margin of error of probability estimates."~`F-5-1-2`,
                           `F-5-3` == "Estimated margin of error of probability estimates."~`F-5-1-3`,
                           `F-5-4` == "Estimated margin of error of probability estimates."~`F-5-1-4`,
                           `F-5-5` == "Estimated margin of error of probability estimates."~`F-5-1-5`,
                           `F-5-6` == "Estimated margin of error of probability estimates."~`F-5-1-6`,
                           `F-5-7` == "Estimated margin of error of probability estimates."~`F-5-1-7`,
                           `F-5-8` == "Estimated margin of error of probability estimates."~`F-5-1-8`),
         weights11 = case_when(`F-5-1` == "Amount of weight given to different factors."~`F-5-1-1`,
                               `F-5-2` == "Amount of weight given to different factors."~`F-5-1-2`,
                               `F-5-3` == "Amount of weight given to different factors."~`F-5-1-3`,
                               `F-5-4` == "Amount of weight given to different factors."~`F-5-1-4`,
                               `F-5-5` == "Amount of weight given to different factors."~`F-5-1-5`,
                               `F-5-6` == "Amount of weight given to different factors."~`F-5-1-6`,
                               `F-5-7` == "Amount of weight given to different factors."~`F-5-1-7`,
                               `F-5-8` == "Amount of weight given to different factors."~`F-5-1-8`),
         accuracy11 = case_when(`F-5-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-1`,
                                `F-5-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-2`,
                                `F-5-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-3`,
                                `F-5-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-4`,
                                `F-5-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-5`,
                                `F-5-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-6`,
                                `F-5-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-7`,
                                `F-5-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-8`),
         human11 = case_when(`F-5-1` == "Human involvement in final estimate (if any)."~`F-5-1-1`,
                             `F-5-2` == "Human involvement in final estimate (if any)."~`F-5-1-2`,
                             `F-5-3` == "Human involvement in final estimate (if any)."~`F-5-1-3`,
                             `F-5-4` == "Human involvement in final estimate (if any)."~`F-5-1-4`,
                             `F-5-5` == "Human involvement in final estimate (if any)."~`F-5-1-5`,
                             `F-5-6` == "Human involvement in final estimate (if any)."~`F-5-1-6`,
                             `F-5-7` == "Human involvement in final estimate (if any)."~`F-5-1-7`,
                             `F-5-8` == "Human involvement in final estimate (if any)."~`F-5-1-8`),
         datasize11 = case_when(`F-5-1` == "Number of cases used to create the algorithm."~`F-5-1-1`,
                                `F-5-2` == "Number of cases used to create the algorithm."~`F-5-1-2`,
                                `F-5-3` == "Number of cases used to create the algorithm."~`F-5-1-3`,
                                `F-5-4` == "Number of cases used to create the algorithm."~`F-5-1-4`,
                                `F-5-5` == "Number of cases used to create the algorithm."~`F-5-1-5`,
                                `F-5-6` == "Number of cases used to create the algorithm."~`F-5-1-6`,
                                `F-5-7` == "Number of cases used to create the algorithm."~`F-5-1-7`,
                                `F-5-8` == "Number of cases used to create the algorithm."~`F-5-1-8`),
         developer11 = case_when(`F-5-1` == "Who developed the algorithm."~`F-5-1-1`,
                                 `F-5-2` == "Who developed the algorithm."~`F-5-1-2`,
                                 `F-5-3` == "Who developed the algorithm."~`F-5-1-3`,
                                 `F-5-4` == "Who developed the algorithm."~`F-5-1-4`,
                                 `F-5-5` == "Who developed the algorithm."~`F-5-1-5`,
                                 `F-5-6` == "Who developed the algorithm."~`F-5-1-6`,
                                 `F-5-7` == "Who developed the algorithm."~`F-5-1-7`,
                                 `F-5-8` == "Who developed the algorithm."~`F-5-1-8`),
         nfactors12 = case_when(`F-5-1` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-1`,
                                `F-5-2` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-2`,
                                `F-5-3` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-3`,
                                `F-5-4` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-4`,
                                `F-5-5` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-5`,
                                `F-5-6` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-6`,
                                `F-5-7` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-7`,
                                `F-5-8` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-8`),
         location12 = case_when(`F-5-1` == "Location from which data to create the algorithm was collected."~`F-5-2-1`,
                                `F-5-2` == "Location from which data to create the algorithm was collected."~`F-5-2-2`,
                                `F-5-3` == "Location from which data to create the algorithm was collected."~`F-5-2-3`,
                                `F-5-4` == "Location from which data to create the algorithm was collected."~`F-5-2-4`,
                                `F-5-5` == "Location from which data to create the algorithm was collected."~`F-5-2-5`,
                                `F-5-6` == "Location from which data to create the algorithm was collected."~`F-5-2-6`,
                                `F-5-7` == "Location from which data to create the algorithm was collected."~`F-5-2-7`,
                                `F-5-8` == "Location from which data to create the algorithm was collected."~`F-5-2-8`),
         moe12 = case_when(`F-5-1` == "Estimated margin of error of probability estimates."~`F-5-2-1`,
                           `F-5-2` == "Estimated margin of error of probability estimates."~`F-5-2-2`,
                           `F-5-3` == "Estimated margin of error of probability estimates."~`F-5-2-3`,
                           `F-5-4` == "Estimated margin of error of probability estimates."~`F-5-2-4`,
                           `F-5-5` == "Estimated margin of error of probability estimates."~`F-5-2-5`,
                           `F-5-6` == "Estimated margin of error of probability estimates."~`F-5-2-6`,
                           `F-5-7` == "Estimated margin of error of probability estimates."~`F-5-2-7`,
                           `F-5-8` == "Estimated margin of error of probability estimates."~`F-5-2-8`),
         weights12 = case_when(`F-5-1` == "Amount of weight given to different factors."~`F-5-2-1`,
                               `F-5-2` == "Amount of weight given to different factors."~`F-5-2-2`,
                               `F-5-3` == "Amount of weight given to different factors."~`F-5-2-3`,
                               `F-5-4` == "Amount of weight given to different factors."~`F-5-2-4`,
                               `F-5-5` == "Amount of weight given to different factors."~`F-5-2-5`,
                               `F-5-6` == "Amount of weight given to different factors."~`F-5-2-6`,
                               `F-5-7` == "Amount of weight given to different factors."~`F-5-2-7`,
                               `F-5-8` == "Amount of weight given to different factors."~`F-5-2-8`),
         accuracy12 = case_when(`F-5-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-1`,
                                `F-5-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-2`,
                                `F-5-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-3`,
                                `F-5-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-4`,
                                `F-5-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-5`,
                                `F-5-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-6`,
                                `F-5-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-7`,
                                `F-5-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-8`),
         human12 = case_when(`F-5-1` == "Human involvement in final estimate (if any)."~`F-5-2-1`,
                             `F-5-2` == "Human involvement in final estimate (if any)."~`F-5-2-2`,
                             `F-5-3` == "Human involvement in final estimate (if any)."~`F-5-2-3`,
                             `F-5-4` == "Human involvement in final estimate (if any)."~`F-5-2-4`,
                             `F-5-5` == "Human involvement in final estimate (if any)."~`F-5-2-5`,
                             `F-5-6` == "Human involvement in final estimate (if any)."~`F-5-2-6`,
                             `F-5-7` == "Human involvement in final estimate (if any)."~`F-5-2-7`,
                             `F-5-8` == "Human involvement in final estimate (if any)."~`F-5-2-8`),
         datasize12 = case_when(`F-5-1` == "Number of cases used to create the algorithm."~`F-5-2-1`,
                                `F-5-2` == "Number of cases used to create the algorithm."~`F-5-2-2`,
                                `F-5-3` == "Number of cases used to create the algorithm."~`F-5-2-3`,
                                `F-5-4` == "Number of cases used to create the algorithm."~`F-5-2-4`,
                                `F-5-5` == "Number of cases used to create the algorithm."~`F-5-2-5`,
                                `F-5-6` == "Number of cases used to create the algorithm."~`F-5-2-6`,
                                `F-5-7` == "Number of cases used to create the algorithm."~`F-5-2-7`,
                                `F-5-8` == "Number of cases used to create the algorithm."~`F-5-2-8`),
         developer12 = case_when(`F-5-1` == "Who developed the algorithm."~`F-5-2-1`,
                                 `F-5-2` == "Who developed the algorithm."~`F-5-2-2`,
                                 `F-5-3` == "Who developed the algorithm."~`F-5-2-3`,
                                 `F-5-4` == "Who developed the algorithm."~`F-5-2-4`,
                                 `F-5-5` == "Who developed the algorithm."~`F-5-2-5`,
                                 `F-5-6` == "Who developed the algorithm."~`F-5-2-6`,
                                 `F-5-7` == "Who developed the algorithm."~`F-5-2-7`,
                                 `F-5-8` == "Who developed the algorithm."~`F-5-2-8`)) %>%
  select(ResponseId, c5c1, c5c2, c51c, c52c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c5c1:c5c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c5c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c5c1", location11, location12)),
         moe= (ifelse(choiceNum == "c5c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c5c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c5c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c5c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c5c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c5c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c5c1", c51c, c52c)),
         defendant = 5,
         sample = "MTurk") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant1a <- conjoint2 %>%
  select(ResponseId, c1c1, c1c2, c11c, c12c, starts_with("F-1")) %>%
  mutate(nfactors11 = case_when(`F-1-1` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-1`,
                                `F-1-2` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-2`,
                                `F-1-3` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-3`,
                                `F-1-4` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-4`,
                                `F-1-5` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-5`,
                                `F-1-6` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-6`,
                                `F-1-7` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-7`,
                                `F-1-8` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-8`),
         location11 = case_when(`F-1-1` == "Location from which data to create the algorithm was collected."~`F-1-1-1`,
                                `F-1-2` == "Location from which data to create the algorithm was collected."~`F-1-1-2`,
                                `F-1-3` == "Location from which data to create the algorithm was collected."~`F-1-1-3`,
                                `F-1-4` == "Location from which data to create the algorithm was collected."~`F-1-1-4`,
                                `F-1-5` == "Location from which data to create the algorithm was collected."~`F-1-1-5`,
                                `F-1-6` == "Location from which data to create the algorithm was collected."~`F-1-1-6`,
                                `F-1-7` == "Location from which data to create the algorithm was collected."~`F-1-1-7`,
                                `F-1-8` == "Location from which data to create the algorithm was collected."~`F-1-1-8`),
         moe11 = case_when(`F-1-1` == "Estimated margin of error of probability estimates."~`F-1-1-1`,
                           `F-1-2` == "Estimated margin of error of probability estimates."~`F-1-1-2`,
                           `F-1-3` == "Estimated margin of error of probability estimates."~`F-1-1-3`,
                           `F-1-4` == "Estimated margin of error of probability estimates."~`F-1-1-4`,
                           `F-1-5` == "Estimated margin of error of probability estimates."~`F-1-1-5`,
                           `F-1-6` == "Estimated margin of error of probability estimates."~`F-1-1-6`,
                           `F-1-7` == "Estimated margin of error of probability estimates."~`F-1-1-7`,
                           `F-1-8` == "Estimated margin of error of probability estimates."~`F-1-1-8`),
         weights11 = case_when(`F-1-1` == "Amount of weight given to different factors."~`F-1-1-1`,
                               `F-1-2` == "Amount of weight given to different factors."~`F-1-1-2`,
                               `F-1-3` == "Amount of weight given to different factors."~`F-1-1-3`,
                               `F-1-4` == "Amount of weight given to different factors."~`F-1-1-4`,
                               `F-1-5` == "Amount of weight given to different factors."~`F-1-1-5`,
                               `F-1-6` == "Amount of weight given to different factors."~`F-1-1-6`,
                               `F-1-7` == "Amount of weight given to different factors."~`F-1-1-7`,
                               `F-1-8` == "Amount of weight given to different factors."~`F-1-1-8`),
         accuracy11 = case_when(`F-1-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-1`,
                                `F-1-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-2`,
                                `F-1-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-3`,
                                `F-1-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-4`,
                                `F-1-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-5`,
                                `F-1-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-6`,
                                `F-1-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-7`,
                                `F-1-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-8`),
         human11 = case_when(`F-1-1` == "Human involvement in final estimate (if any)."~`F-1-1-1`,
                             `F-1-2` == "Human involvement in final estimate (if any)."~`F-1-1-2`,
                             `F-1-3` == "Human involvement in final estimate (if any)."~`F-1-1-3`,
                             `F-1-4` == "Human involvement in final estimate (if any)."~`F-1-1-4`,
                             `F-1-5` == "Human involvement in final estimate (if any)."~`F-1-1-5`,
                             `F-1-6` == "Human involvement in final estimate (if any)."~`F-1-1-6`,
                             `F-1-7` == "Human involvement in final estimate (if any)."~`F-1-1-7`,
                             `F-1-8` == "Human involvement in final estimate (if any)."~`F-1-1-8`),
         datasize11 = case_when(`F-1-1` == "Number of cases used to create the algorithm."~`F-1-1-1`,
                                `F-1-2` == "Number of cases used to create the algorithm."~`F-1-1-2`,
                                `F-1-3` == "Number of cases used to create the algorithm."~`F-1-1-3`,
                                `F-1-4` == "Number of cases used to create the algorithm."~`F-1-1-4`,
                                `F-1-5` == "Number of cases used to create the algorithm."~`F-1-1-5`,
                                `F-1-6` == "Number of cases used to create the algorithm."~`F-1-1-6`,
                                `F-1-7` == "Number of cases used to create the algorithm."~`F-1-1-7`,
                                `F-1-8` == "Number of cases used to create the algorithm."~`F-1-1-8`),
         developer11 = case_when(`F-1-1` == "Who developed the algorithm."~`F-1-1-1`,
                                 `F-1-2` == "Who developed the algorithm."~`F-1-1-2`,
                                 `F-1-3` == "Who developed the algorithm."~`F-1-1-3`,
                                 `F-1-4` == "Who developed the algorithm."~`F-1-1-4`,
                                 `F-1-5` == "Who developed the algorithm."~`F-1-1-5`,
                                 `F-1-6` == "Who developed the algorithm."~`F-1-1-6`,
                                 `F-1-7` == "Who developed the algorithm."~`F-1-1-7`,
                                 `F-1-8` == "Who developed the algorithm."~`F-1-1-8`),
         nfactors12 = case_when(`F-1-1` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-1`,
                                `F-1-2` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-2`,
                                `F-1-3` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-3`,
                                `F-1-4` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-4`,
                                `F-1-5` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-5`,
                                `F-1-6` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-6`,
                                `F-1-7` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-7`,
                                `F-1-8` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-8`),
         location12 = case_when(`F-1-1` == "Location from which data to create the algorithm was collected."~`F-1-2-1`,
                                `F-1-2` == "Location from which data to create the algorithm was collected."~`F-1-2-2`,
                                `F-1-3` == "Location from which data to create the algorithm was collected."~`F-1-2-3`,
                                `F-1-4` == "Location from which data to create the algorithm was collected."~`F-1-2-4`,
                                `F-1-5` == "Location from which data to create the algorithm was collected."~`F-1-2-5`,
                                `F-1-6` == "Location from which data to create the algorithm was collected."~`F-1-2-6`,
                                `F-1-7` == "Location from which data to create the algorithm was collected."~`F-1-2-7`,
                                `F-1-8` == "Location from which data to create the algorithm was collected."~`F-1-2-8`),
         moe12 = case_when(`F-1-1` == "Estimated margin of error of probability estimates."~`F-1-2-1`,
                           `F-1-2` == "Estimated margin of error of probability estimates."~`F-1-2-2`,
                           `F-1-3` == "Estimated margin of error of probability estimates."~`F-1-2-3`,
                           `F-1-4` == "Estimated margin of error of probability estimates."~`F-1-2-4`,
                           `F-1-5` == "Estimated margin of error of probability estimates."~`F-1-2-5`,
                           `F-1-6` == "Estimated margin of error of probability estimates."~`F-1-2-6`,
                           `F-1-7` == "Estimated margin of error of probability estimates."~`F-1-2-7`,
                           `F-1-8` == "Estimated margin of error of probability estimates."~`F-1-2-8`),
         weights12 = case_when(`F-1-1` == "Amount of weight given to different factors."~`F-1-2-1`,
                               `F-1-2` == "Amount of weight given to different factors."~`F-1-2-2`,
                               `F-1-3` == "Amount of weight given to different factors."~`F-1-2-3`,
                               `F-1-4` == "Amount of weight given to different factors."~`F-1-2-4`,
                               `F-1-5` == "Amount of weight given to different factors."~`F-1-2-5`,
                               `F-1-6` == "Amount of weight given to different factors."~`F-1-2-6`,
                               `F-1-7` == "Amount of weight given to different factors."~`F-1-2-7`,
                               `F-1-8` == "Amount of weight given to different factors."~`F-1-2-8`),
         accuracy12 = case_when(`F-1-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-1`,
                                `F-1-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-2`,
                                `F-1-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-3`,
                                `F-1-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-4`,
                                `F-1-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-5`,
                                `F-1-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-6`,
                                `F-1-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-7`,
                                `F-1-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-8`),
         human12 = case_when(`F-1-1` == "Human involvement in final estimate (if any)."~`F-1-2-1`,
                             `F-1-2` == "Human involvement in final estimate (if any)."~`F-1-2-2`,
                             `F-1-3` == "Human involvement in final estimate (if any)."~`F-1-2-3`,
                             `F-1-4` == "Human involvement in final estimate (if any)."~`F-1-2-4`,
                             `F-1-5` == "Human involvement in final estimate (if any)."~`F-1-2-5`,
                             `F-1-6` == "Human involvement in final estimate (if any)."~`F-1-2-6`,
                             `F-1-7` == "Human involvement in final estimate (if any)."~`F-1-2-7`,
                             `F-1-8` == "Human involvement in final estimate (if any)."~`F-1-2-8`),
         datasize12 = case_when(`F-1-1` == "Number of cases used to create the algorithm."~`F-1-2-1`,
                                `F-1-2` == "Number of cases used to create the algorithm."~`F-1-2-2`,
                                `F-1-3` == "Number of cases used to create the algorithm."~`F-1-2-3`,
                                `F-1-4` == "Number of cases used to create the algorithm."~`F-1-2-4`,
                                `F-1-5` == "Number of cases used to create the algorithm."~`F-1-2-5`,
                                `F-1-6` == "Number of cases used to create the algorithm."~`F-1-2-6`,
                                `F-1-7` == "Number of cases used to create the algorithm."~`F-1-2-7`,
                                `F-1-8` == "Number of cases used to create the algorithm."~`F-1-2-8`),
         developer12 = case_when(`F-1-1` == "Who developed the algorithm."~`F-1-2-1`,
                                 `F-1-2` == "Who developed the algorithm."~`F-1-2-2`,
                                 `F-1-3` == "Who developed the algorithm."~`F-1-2-3`,
                                 `F-1-4` == "Who developed the algorithm."~`F-1-2-4`,
                                 `F-1-5` == "Who developed the algorithm."~`F-1-2-5`,
                                 `F-1-6` == "Who developed the algorithm."~`F-1-2-6`,
                                 `F-1-7` == "Who developed the algorithm."~`F-1-2-7`,
                                 `F-1-8` == "Who developed the algorithm."~`F-1-2-8`)) %>%
  select(ResponseId, c1c1, c1c2, c11c, c12c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c1c1:c1c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c1c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c1c1", location11, location12)),
         moe= (ifelse(choiceNum == "c1c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c1c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c1c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c1c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c1c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c1c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c1c1", c11c, c12c)),
         defendant = 1,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant2a <- conjoint2 %>%
  select(ResponseId, c2c1, c2c2, c21c, c22c, starts_with("F-2")) %>%
  mutate(nfactors11 = case_when(`F-2-1` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-1`,
                                `F-2-2` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-2`,
                                `F-2-3` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-3`,
                                `F-2-4` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-4`,
                                `F-2-5` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-5`,
                                `F-2-6` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-6`,
                                `F-2-7` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-7`,
                                `F-2-8` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-8`),
         location11 = case_when(`F-2-1` == "Location from which data to create the algorithm was collected."~`F-2-1-1`,
                                `F-2-2` == "Location from which data to create the algorithm was collected."~`F-2-1-2`,
                                `F-2-3` == "Location from which data to create the algorithm was collected."~`F-2-1-3`,
                                `F-2-4` == "Location from which data to create the algorithm was collected."~`F-2-1-4`,
                                `F-2-5` == "Location from which data to create the algorithm was collected."~`F-2-1-5`,
                                `F-2-6` == "Location from which data to create the algorithm was collected."~`F-2-1-6`,
                                `F-2-7` == "Location from which data to create the algorithm was collected."~`F-2-1-7`,
                                `F-2-8` == "Location from which data to create the algorithm was collected."~`F-2-1-8`),
         moe11 = case_when(`F-2-1` == "Estimated margin of error of probability estimates."~`F-2-1-1`,
                           `F-2-2` == "Estimated margin of error of probability estimates."~`F-2-1-2`,
                           `F-2-3` == "Estimated margin of error of probability estimates."~`F-2-1-3`,
                           `F-2-4` == "Estimated margin of error of probability estimates."~`F-2-1-4`,
                           `F-2-5` == "Estimated margin of error of probability estimates."~`F-2-1-5`,
                           `F-2-6` == "Estimated margin of error of probability estimates."~`F-2-1-6`,
                           `F-2-7` == "Estimated margin of error of probability estimates."~`F-2-1-7`,
                           `F-2-8` == "Estimated margin of error of probability estimates."~`F-2-1-8`),
         weights11 = case_when(`F-2-1` == "Amount of weight given to different factors."~`F-2-1-1`,
                               `F-2-2` == "Amount of weight given to different factors."~`F-2-1-2`,
                               `F-2-3` == "Amount of weight given to different factors."~`F-2-1-3`,
                               `F-2-4` == "Amount of weight given to different factors."~`F-2-1-4`,
                               `F-2-5` == "Amount of weight given to different factors."~`F-2-1-5`,
                               `F-2-6` == "Amount of weight given to different factors."~`F-2-1-6`,
                               `F-2-7` == "Amount of weight given to different factors."~`F-2-1-7`,
                               `F-2-8` == "Amount of weight given to different factors."~`F-2-1-8`),
         accuracy11 = case_when(`F-2-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-1`,
                                `F-2-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-2`,
                                `F-2-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-3`,
                                `F-2-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-4`,
                                `F-2-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-5`,
                                `F-2-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-6`,
                                `F-2-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-7`,
                                `F-2-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-8`),
         human11 = case_when(`F-2-1` == "Human involvement in final estimate (if any)."~`F-2-1-1`,
                             `F-2-2` == "Human involvement in final estimate (if any)."~`F-2-1-2`,
                             `F-2-3` == "Human involvement in final estimate (if any)."~`F-2-1-3`,
                             `F-2-4` == "Human involvement in final estimate (if any)."~`F-2-1-4`,
                             `F-2-5` == "Human involvement in final estimate (if any)."~`F-2-1-5`,
                             `F-2-6` == "Human involvement in final estimate (if any)."~`F-2-1-6`,
                             `F-2-7` == "Human involvement in final estimate (if any)."~`F-2-1-7`,
                             `F-2-8` == "Human involvement in final estimate (if any)."~`F-2-1-8`),
         datasize11 = case_when(`F-2-1` == "Number of cases used to create the algorithm."~`F-2-1-1`,
                                `F-2-2` == "Number of cases used to create the algorithm."~`F-2-1-2`,
                                `F-2-3` == "Number of cases used to create the algorithm."~`F-2-1-3`,
                                `F-2-4` == "Number of cases used to create the algorithm."~`F-2-1-4`,
                                `F-2-5` == "Number of cases used to create the algorithm."~`F-2-1-5`,
                                `F-2-6` == "Number of cases used to create the algorithm."~`F-2-1-6`,
                                `F-2-7` == "Number of cases used to create the algorithm."~`F-2-1-7`,
                                `F-2-8` == "Number of cases used to create the algorithm."~`F-2-1-8`),
         developer11 = case_when(`F-2-1` == "Who developed the algorithm."~`F-2-1-1`,
                                 `F-2-2` == "Who developed the algorithm."~`F-2-1-2`,
                                 `F-2-3` == "Who developed the algorithm."~`F-2-1-3`,
                                 `F-2-4` == "Who developed the algorithm."~`F-2-1-4`,
                                 `F-2-5` == "Who developed the algorithm."~`F-2-1-5`,
                                 `F-2-6` == "Who developed the algorithm."~`F-2-1-6`,
                                 `F-2-7` == "Who developed the algorithm."~`F-2-1-7`,
                                 `F-2-8` == "Who developed the algorithm."~`F-2-1-8`),
         nfactors12 = case_when(`F-2-1` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-1`,
                                `F-2-2` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-2`,
                                `F-2-3` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-3`,
                                `F-2-4` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-4`,
                                `F-2-5` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-5`,
                                `F-2-6` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-6`,
                                `F-2-7` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-7`,
                                `F-2-8` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-8`),
         location12 = case_when(`F-2-1` == "Location from which data to create the algorithm was collected."~`F-2-2-1`,
                                `F-2-2` == "Location from which data to create the algorithm was collected."~`F-2-2-2`,
                                `F-2-3` == "Location from which data to create the algorithm was collected."~`F-2-2-3`,
                                `F-2-4` == "Location from which data to create the algorithm was collected."~`F-2-2-4`,
                                `F-2-5` == "Location from which data to create the algorithm was collected."~`F-2-2-5`,
                                `F-2-6` == "Location from which data to create the algorithm was collected."~`F-2-2-6`,
                                `F-2-7` == "Location from which data to create the algorithm was collected."~`F-2-2-7`,
                                `F-2-8` == "Location from which data to create the algorithm was collected."~`F-2-2-8`),
         moe12 = case_when(`F-2-1` == "Estimated margin of error of probability estimates."~`F-2-2-1`,
                           `F-2-2` == "Estimated margin of error of probability estimates."~`F-2-2-2`,
                           `F-2-3` == "Estimated margin of error of probability estimates."~`F-2-2-3`,
                           `F-2-4` == "Estimated margin of error of probability estimates."~`F-2-2-4`,
                           `F-2-5` == "Estimated margin of error of probability estimates."~`F-2-2-5`,
                           `F-2-6` == "Estimated margin of error of probability estimates."~`F-2-2-6`,
                           `F-2-7` == "Estimated margin of error of probability estimates."~`F-2-2-7`,
                           `F-2-8` == "Estimated margin of error of probability estimates."~`F-2-2-8`),
         weights12 = case_when(`F-2-1` == "Amount of weight given to different factors."~`F-2-2-1`,
                               `F-2-2` == "Amount of weight given to different factors."~`F-2-2-2`,
                               `F-2-3` == "Amount of weight given to different factors."~`F-2-2-3`,
                               `F-2-4` == "Amount of weight given to different factors."~`F-2-2-4`,
                               `F-2-5` == "Amount of weight given to different factors."~`F-2-2-5`,
                               `F-2-6` == "Amount of weight given to different factors."~`F-2-2-6`,
                               `F-2-7` == "Amount of weight given to different factors."~`F-2-2-7`,
                               `F-2-8` == "Amount of weight given to different factors."~`F-2-2-8`),
         accuracy12 = case_when(`F-2-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-1`,
                                `F-2-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-2`,
                                `F-2-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-3`,
                                `F-2-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-4`,
                                `F-2-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-5`,
                                `F-2-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-6`,
                                `F-2-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-7`,
                                `F-2-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-8`),
         human12 = case_when(`F-2-1` == "Human involvement in final estimate (if any)."~`F-2-2-1`,
                             `F-2-2` == "Human involvement in final estimate (if any)."~`F-2-2-2`,
                             `F-2-3` == "Human involvement in final estimate (if any)."~`F-2-2-3`,
                             `F-2-4` == "Human involvement in final estimate (if any)."~`F-2-2-4`,
                             `F-2-5` == "Human involvement in final estimate (if any)."~`F-2-2-5`,
                             `F-2-6` == "Human involvement in final estimate (if any)."~`F-2-2-6`,
                             `F-2-7` == "Human involvement in final estimate (if any)."~`F-2-2-7`,
                             `F-2-8` == "Human involvement in final estimate (if any)."~`F-2-2-8`),
         datasize12 = case_when(`F-2-1` == "Number of cases used to create the algorithm."~`F-2-2-1`,
                                `F-2-2` == "Number of cases used to create the algorithm."~`F-2-2-2`,
                                `F-2-3` == "Number of cases used to create the algorithm."~`F-2-2-3`,
                                `F-2-4` == "Number of cases used to create the algorithm."~`F-2-2-4`,
                                `F-2-5` == "Number of cases used to create the algorithm."~`F-2-2-5`,
                                `F-2-6` == "Number of cases used to create the algorithm."~`F-2-2-6`,
                                `F-2-7` == "Number of cases used to create the algorithm."~`F-2-2-7`,
                                `F-2-8` == "Number of cases used to create the algorithm."~`F-2-2-8`),
         developer12 = case_when(`F-2-1` == "Who developed the algorithm."~`F-2-2-1`,
                                 `F-2-2` == "Who developed the algorithm."~`F-2-2-2`,
                                 `F-2-3` == "Who developed the algorithm."~`F-2-2-3`,
                                 `F-2-4` == "Who developed the algorithm."~`F-2-2-4`,
                                 `F-2-5` == "Who developed the algorithm."~`F-2-2-5`,
                                 `F-2-6` == "Who developed the algorithm."~`F-2-2-6`,
                                 `F-2-7` == "Who developed the algorithm."~`F-2-2-7`,
                                 `F-2-8` == "Who developed the algorithm."~`F-2-2-8`)) %>%
  select(ResponseId, c2c1, c2c2, c21c, c22c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c2c1:c2c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c2c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c2c1", location11, location12)),
         moe= (ifelse(choiceNum == "c2c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c2c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c2c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c2c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c2c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c2c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c2c1", c21c, c22c)),
         defendant = 2,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant3a <- conjoint2 %>%
  select(ResponseId, c3c1, c3c2, c31c, c32c, starts_with("F-3")) %>%
  mutate(nfactors11 = case_when(`F-3-1` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-1`,
                                `F-3-2` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-2`,
                                `F-3-3` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-3`,
                                `F-3-4` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-4`,
                                `F-3-5` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-5`,
                                `F-3-6` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-6`,
                                `F-3-7` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-7`,
                                `F-3-8` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-8`),
         location11 = case_when(`F-3-1` == "Location from which data to create the algorithm was collected."~`F-3-1-1`,
                                `F-3-2` == "Location from which data to create the algorithm was collected."~`F-3-1-2`,
                                `F-3-3` == "Location from which data to create the algorithm was collected."~`F-3-1-3`,
                                `F-3-4` == "Location from which data to create the algorithm was collected."~`F-3-1-4`,
                                `F-3-5` == "Location from which data to create the algorithm was collected."~`F-3-1-5`,
                                `F-3-6` == "Location from which data to create the algorithm was collected."~`F-3-1-6`,
                                `F-3-7` == "Location from which data to create the algorithm was collected."~`F-3-1-7`,
                                `F-3-8` == "Location from which data to create the algorithm was collected."~`F-3-1-8`),
         moe11 = case_when(`F-3-1` == "Estimated margin of error of probability estimates."~`F-3-1-1`,
                           `F-3-2` == "Estimated margin of error of probability estimates."~`F-3-1-2`,
                           `F-3-3` == "Estimated margin of error of probability estimates."~`F-3-1-3`,
                           `F-3-4` == "Estimated margin of error of probability estimates."~`F-3-1-4`,
                           `F-3-5` == "Estimated margin of error of probability estimates."~`F-3-1-5`,
                           `F-3-6` == "Estimated margin of error of probability estimates."~`F-3-1-6`,
                           `F-3-7` == "Estimated margin of error of probability estimates."~`F-3-1-7`,
                           `F-3-8` == "Estimated margin of error of probability estimates."~`F-3-1-8`),
         weights11 = case_when(`F-3-1` == "Amount of weight given to different factors."~`F-3-1-1`,
                               `F-3-2` == "Amount of weight given to different factors."~`F-3-1-2`,
                               `F-3-3` == "Amount of weight given to different factors."~`F-3-1-3`,
                               `F-3-4` == "Amount of weight given to different factors."~`F-3-1-4`,
                               `F-3-5` == "Amount of weight given to different factors."~`F-3-1-5`,
                               `F-3-6` == "Amount of weight given to different factors."~`F-3-1-6`,
                               `F-3-7` == "Amount of weight given to different factors."~`F-3-1-7`,
                               `F-3-8` == "Amount of weight given to different factors."~`F-3-1-8`),
         accuracy11 = case_when(`F-3-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-1`,
                                `F-3-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-2`,
                                `F-3-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-3`,
                                `F-3-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-4`,
                                `F-3-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-5`,
                                `F-3-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-6`,
                                `F-3-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-7`,
                                `F-3-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-8`),
         human11 = case_when(`F-3-1` == "Human involvement in final estimate (if any)."~`F-3-1-1`,
                             `F-3-2` == "Human involvement in final estimate (if any)."~`F-3-1-2`,
                             `F-3-3` == "Human involvement in final estimate (if any)."~`F-3-1-3`,
                             `F-3-4` == "Human involvement in final estimate (if any)."~`F-3-1-4`,
                             `F-3-5` == "Human involvement in final estimate (if any)."~`F-3-1-5`,
                             `F-3-6` == "Human involvement in final estimate (if any)."~`F-3-1-6`,
                             `F-3-7` == "Human involvement in final estimate (if any)."~`F-3-1-7`,
                             `F-3-8` == "Human involvement in final estimate (if any)."~`F-3-1-8`),
         datasize11 = case_when(`F-3-1` == "Number of cases used to create the algorithm."~`F-3-1-1`,
                                `F-3-2` == "Number of cases used to create the algorithm."~`F-3-1-2`,
                                `F-3-3` == "Number of cases used to create the algorithm."~`F-3-1-3`,
                                `F-3-4` == "Number of cases used to create the algorithm."~`F-3-1-4`,
                                `F-3-5` == "Number of cases used to create the algorithm."~`F-3-1-5`,
                                `F-3-6` == "Number of cases used to create the algorithm."~`F-3-1-6`,
                                `F-3-7` == "Number of cases used to create the algorithm."~`F-3-1-7`,
                                `F-3-8` == "Number of cases used to create the algorithm."~`F-3-1-8`),
         developer11 = case_when(`F-3-1` == "Who developed the algorithm."~`F-3-1-1`,
                                 `F-3-2` == "Who developed the algorithm."~`F-3-1-2`,
                                 `F-3-3` == "Who developed the algorithm."~`F-3-1-3`,
                                 `F-3-4` == "Who developed the algorithm."~`F-3-1-4`,
                                 `F-3-5` == "Who developed the algorithm."~`F-3-1-5`,
                                 `F-3-6` == "Who developed the algorithm."~`F-3-1-6`,
                                 `F-3-7` == "Who developed the algorithm."~`F-3-1-7`,
                                 `F-3-8` == "Who developed the algorithm."~`F-3-1-8`),
         nfactors12 = case_when(`F-3-1` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-1`,
                                `F-3-2` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-2`,
                                `F-3-3` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-3`,
                                `F-3-4` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-4`,
                                `F-3-5` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-5`,
                                `F-3-6` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-6`,
                                `F-3-7` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-7`,
                                `F-3-8` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-8`),
         location12 = case_when(`F-3-1` == "Location from which data to create the algorithm was collected."~`F-3-2-1`,
                                `F-3-2` == "Location from which data to create the algorithm was collected."~`F-3-2-2`,
                                `F-3-3` == "Location from which data to create the algorithm was collected."~`F-3-2-3`,
                                `F-3-4` == "Location from which data to create the algorithm was collected."~`F-3-2-4`,
                                `F-3-5` == "Location from which data to create the algorithm was collected."~`F-3-2-5`,
                                `F-3-6` == "Location from which data to create the algorithm was collected."~`F-3-2-6`,
                                `F-3-7` == "Location from which data to create the algorithm was collected."~`F-3-2-7`,
                                `F-3-8` == "Location from which data to create the algorithm was collected."~`F-3-2-8`),
         moe12 = case_when(`F-3-1` == "Estimated margin of error of probability estimates."~`F-3-2-1`,
                           `F-3-2` == "Estimated margin of error of probability estimates."~`F-3-2-2`,
                           `F-3-3` == "Estimated margin of error of probability estimates."~`F-3-2-3`,
                           `F-3-4` == "Estimated margin of error of probability estimates."~`F-3-2-4`,
                           `F-3-5` == "Estimated margin of error of probability estimates."~`F-3-2-5`,
                           `F-3-6` == "Estimated margin of error of probability estimates."~`F-3-2-6`,
                           `F-3-7` == "Estimated margin of error of probability estimates."~`F-3-2-7`,
                           `F-3-8` == "Estimated margin of error of probability estimates."~`F-3-2-8`),
         weights12 = case_when(`F-3-1` == "Amount of weight given to different factors."~`F-3-2-1`,
                               `F-3-2` == "Amount of weight given to different factors."~`F-3-2-2`,
                               `F-3-3` == "Amount of weight given to different factors."~`F-3-2-3`,
                               `F-3-4` == "Amount of weight given to different factors."~`F-3-2-4`,
                               `F-3-5` == "Amount of weight given to different factors."~`F-3-2-5`,
                               `F-3-6` == "Amount of weight given to different factors."~`F-3-2-6`,
                               `F-3-7` == "Amount of weight given to different factors."~`F-3-2-7`,
                               `F-3-8` == "Amount of weight given to different factors."~`F-3-2-8`),
         accuracy12 = case_when(`F-3-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-1`,
                                `F-3-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-2`,
                                `F-3-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-3`,
                                `F-3-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-4`,
                                `F-3-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-5`,
                                `F-3-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-6`,
                                `F-3-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-7`,
                                `F-3-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-8`),
         human12 = case_when(`F-3-1` == "Human involvement in final estimate (if any)."~`F-3-2-1`,
                             `F-3-2` == "Human involvement in final estimate (if any)."~`F-3-2-2`,
                             `F-3-3` == "Human involvement in final estimate (if any)."~`F-3-2-3`,
                             `F-3-4` == "Human involvement in final estimate (if any)."~`F-3-2-4`,
                             `F-3-5` == "Human involvement in final estimate (if any)."~`F-3-2-5`,
                             `F-3-6` == "Human involvement in final estimate (if any)."~`F-3-2-6`,
                             `F-3-7` == "Human involvement in final estimate (if any)."~`F-3-2-7`,
                             `F-3-8` == "Human involvement in final estimate (if any)."~`F-3-2-8`),
         datasize12 = case_when(`F-3-1` == "Number of cases used to create the algorithm."~`F-3-2-1`,
                                `F-3-2` == "Number of cases used to create the algorithm."~`F-3-2-2`,
                                `F-3-3` == "Number of cases used to create the algorithm."~`F-3-2-3`,
                                `F-3-4` == "Number of cases used to create the algorithm."~`F-3-2-4`,
                                `F-3-5` == "Number of cases used to create the algorithm."~`F-3-2-5`,
                                `F-3-6` == "Number of cases used to create the algorithm."~`F-3-2-6`,
                                `F-3-7` == "Number of cases used to create the algorithm."~`F-3-2-7`,
                                `F-3-8` == "Number of cases used to create the algorithm."~`F-3-2-8`),
         developer12 = case_when(`F-3-1` == "Who developed the algorithm."~`F-3-2-1`,
                                 `F-3-2` == "Who developed the algorithm."~`F-3-2-2`,
                                 `F-3-3` == "Who developed the algorithm."~`F-3-2-3`,
                                 `F-3-4` == "Who developed the algorithm."~`F-3-2-4`,
                                 `F-3-5` == "Who developed the algorithm."~`F-3-2-5`,
                                 `F-3-6` == "Who developed the algorithm."~`F-3-2-6`,
                                 `F-3-7` == "Who developed the algorithm."~`F-3-2-7`,
                                 `F-3-8` == "Who developed the algorithm."~`F-3-2-8`)) %>%
  select(ResponseId, c3c1, c3c2, c31c, c32c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c3c1:c3c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c3c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c3c1", location11, location12)),
         moe= (ifelse(choiceNum == "c3c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c3c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c3c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c3c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c3c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c3c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c3c1", c31c, c32c)),
         defendant = 3,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant4a <- conjoint2 %>%
  select(ResponseId, c4c1, c4c2, c41c, c42c, starts_with("F-4")) %>%
  mutate(nfactors11 = case_when(`F-4-1` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-1`,
                                `F-4-2` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-2`,
                                `F-4-3` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-3`,
                                `F-4-4` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-4`,
                                `F-4-5` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-5`,
                                `F-4-6` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-6`,
                                `F-4-7` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-7`,
                                `F-4-8` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-8`),
         location11 = case_when(`F-4-1` == "Location from which data to create the algorithm was collected."~`F-4-1-1`,
                                `F-4-2` == "Location from which data to create the algorithm was collected."~`F-4-1-2`,
                                `F-4-3` == "Location from which data to create the algorithm was collected."~`F-4-1-3`,
                                `F-4-4` == "Location from which data to create the algorithm was collected."~`F-4-1-4`,
                                `F-4-5` == "Location from which data to create the algorithm was collected."~`F-4-1-5`,
                                `F-4-6` == "Location from which data to create the algorithm was collected."~`F-4-1-6`,
                                `F-4-7` == "Location from which data to create the algorithm was collected."~`F-4-1-7`,
                                `F-4-8` == "Location from which data to create the algorithm was collected."~`F-4-1-8`),
         moe11 = case_when(`F-4-1` == "Estimated margin of error of probability estimates."~`F-4-1-1`,
                           `F-4-2` == "Estimated margin of error of probability estimates."~`F-4-1-2`,
                           `F-4-3` == "Estimated margin of error of probability estimates."~`F-4-1-3`,
                           `F-4-4` == "Estimated margin of error of probability estimates."~`F-4-1-4`,
                           `F-4-5` == "Estimated margin of error of probability estimates."~`F-4-1-5`,
                           `F-4-6` == "Estimated margin of error of probability estimates."~`F-4-1-6`,
                           `F-4-7` == "Estimated margin of error of probability estimates."~`F-4-1-7`,
                           `F-4-8` == "Estimated margin of error of probability estimates."~`F-4-1-8`),
         weights11 = case_when(`F-4-1` == "Amount of weight given to different factors."~`F-4-1-1`,
                               `F-4-2` == "Amount of weight given to different factors."~`F-4-1-2`,
                               `F-4-3` == "Amount of weight given to different factors."~`F-4-1-3`,
                               `F-4-4` == "Amount of weight given to different factors."~`F-4-1-4`,
                               `F-4-5` == "Amount of weight given to different factors."~`F-4-1-5`,
                               `F-4-6` == "Amount of weight given to different factors."~`F-4-1-6`,
                               `F-4-7` == "Amount of weight given to different factors."~`F-4-1-7`,
                               `F-4-8` == "Amount of weight given to different factors."~`F-4-1-8`),
         accuracy11 = case_when(`F-4-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-1`,
                                `F-4-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-2`,
                                `F-4-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-3`,
                                `F-4-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-4`,
                                `F-4-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-5`,
                                `F-4-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-6`,
                                `F-4-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-7`,
                                `F-4-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-8`),
         human11 = case_when(`F-4-1` == "Human involvement in final estimate (if any)."~`F-4-1-1`,
                             `F-4-2` == "Human involvement in final estimate (if any)."~`F-4-1-2`,
                             `F-4-3` == "Human involvement in final estimate (if any)."~`F-4-1-3`,
                             `F-4-4` == "Human involvement in final estimate (if any)."~`F-4-1-4`,
                             `F-4-5` == "Human involvement in final estimate (if any)."~`F-4-1-5`,
                             `F-4-6` == "Human involvement in final estimate (if any)."~`F-4-1-6`,
                             `F-4-7` == "Human involvement in final estimate (if any)."~`F-4-1-7`,
                             `F-4-8` == "Human involvement in final estimate (if any)."~`F-4-1-8`),
         datasize11 = case_when(`F-4-1` == "Number of cases used to create the algorithm."~`F-4-1-1`,
                                `F-4-2` == "Number of cases used to create the algorithm."~`F-4-1-2`,
                                `F-4-3` == "Number of cases used to create the algorithm."~`F-4-1-3`,
                                `F-4-4` == "Number of cases used to create the algorithm."~`F-4-1-4`,
                                `F-4-5` == "Number of cases used to create the algorithm."~`F-4-1-5`,
                                `F-4-6` == "Number of cases used to create the algorithm."~`F-4-1-6`,
                                `F-4-7` == "Number of cases used to create the algorithm."~`F-4-1-7`,
                                `F-4-8` == "Number of cases used to create the algorithm."~`F-4-1-8`),
         developer11 = case_when(`F-4-1` == "Who developed the algorithm."~`F-4-1-1`,
                                 `F-4-2` == "Who developed the algorithm."~`F-4-1-2`,
                                 `F-4-3` == "Who developed the algorithm."~`F-4-1-3`,
                                 `F-4-4` == "Who developed the algorithm."~`F-4-1-4`,
                                 `F-4-5` == "Who developed the algorithm."~`F-4-1-5`,
                                 `F-4-6` == "Who developed the algorithm."~`F-4-1-6`,
                                 `F-4-7` == "Who developed the algorithm."~`F-4-1-7`,
                                 `F-4-8` == "Who developed the algorithm."~`F-4-1-8`),
         nfactors12 = case_when(`F-4-1` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-1`,
                                `F-4-2` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-2`,
                                `F-4-3` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-3`,
                                `F-4-4` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-4`,
                                `F-4-5` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-5`,
                                `F-4-6` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-6`,
                                `F-4-7` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-7`,
                                `F-4-8` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-8`),
         location12 = case_when(`F-4-1` == "Location from which data to create the algorithm was collected."~`F-4-2-1`,
                                `F-4-2` == "Location from which data to create the algorithm was collected."~`F-4-2-2`,
                                `F-4-3` == "Location from which data to create the algorithm was collected."~`F-4-2-3`,
                                `F-4-4` == "Location from which data to create the algorithm was collected."~`F-4-2-4`,
                                `F-4-5` == "Location from which data to create the algorithm was collected."~`F-4-2-5`,
                                `F-4-6` == "Location from which data to create the algorithm was collected."~`F-4-2-6`,
                                `F-4-7` == "Location from which data to create the algorithm was collected."~`F-4-2-7`,
                                `F-4-8` == "Location from which data to create the algorithm was collected."~`F-4-2-8`),
         moe12 = case_when(`F-4-1` == "Estimated margin of error of probability estimates."~`F-4-2-1`,
                           `F-4-2` == "Estimated margin of error of probability estimates."~`F-4-2-2`,
                           `F-4-3` == "Estimated margin of error of probability estimates."~`F-4-2-3`,
                           `F-4-4` == "Estimated margin of error of probability estimates."~`F-4-2-4`,
                           `F-4-5` == "Estimated margin of error of probability estimates."~`F-4-2-5`,
                           `F-4-6` == "Estimated margin of error of probability estimates."~`F-4-2-6`,
                           `F-4-7` == "Estimated margin of error of probability estimates."~`F-4-2-7`,
                           `F-4-8` == "Estimated margin of error of probability estimates."~`F-4-2-8`),
         weights12 = case_when(`F-4-1` == "Amount of weight given to different factors."~`F-4-2-1`,
                               `F-4-2` == "Amount of weight given to different factors."~`F-4-2-2`,
                               `F-4-3` == "Amount of weight given to different factors."~`F-4-2-3`,
                               `F-4-4` == "Amount of weight given to different factors."~`F-4-2-4`,
                               `F-4-5` == "Amount of weight given to different factors."~`F-4-2-5`,
                               `F-4-6` == "Amount of weight given to different factors."~`F-4-2-6`,
                               `F-4-7` == "Amount of weight given to different factors."~`F-4-2-7`,
                               `F-4-8` == "Amount of weight given to different factors."~`F-4-2-8`),
         accuracy12 = case_when(`F-4-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-1`,
                                `F-4-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-2`,
                                `F-4-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-3`,
                                `F-4-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-4`,
                                `F-4-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-5`,
                                `F-4-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-6`,
                                `F-4-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-7`,
                                `F-4-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-8`),
         human12 = case_when(`F-4-1` == "Human involvement in final estimate (if any)."~`F-4-2-1`,
                             `F-4-2` == "Human involvement in final estimate (if any)."~`F-4-2-2`,
                             `F-4-3` == "Human involvement in final estimate (if any)."~`F-4-2-3`,
                             `F-4-4` == "Human involvement in final estimate (if any)."~`F-4-2-4`,
                             `F-4-5` == "Human involvement in final estimate (if any)."~`F-4-2-5`,
                             `F-4-6` == "Human involvement in final estimate (if any)."~`F-4-2-6`,
                             `F-4-7` == "Human involvement in final estimate (if any)."~`F-4-2-7`,
                             `F-4-8` == "Human involvement in final estimate (if any)."~`F-4-2-8`),
         datasize12 = case_when(`F-4-1` == "Number of cases used to create the algorithm."~`F-4-2-1`,
                                `F-4-2` == "Number of cases used to create the algorithm."~`F-4-2-2`,
                                `F-4-3` == "Number of cases used to create the algorithm."~`F-4-2-3`,
                                `F-4-4` == "Number of cases used to create the algorithm."~`F-4-2-4`,
                                `F-4-5` == "Number of cases used to create the algorithm."~`F-4-2-5`,
                                `F-4-6` == "Number of cases used to create the algorithm."~`F-4-2-6`,
                                `F-4-7` == "Number of cases used to create the algorithm."~`F-4-2-7`,
                                `F-4-8` == "Number of cases used to create the algorithm."~`F-4-2-8`),
         developer12 = case_when(`F-4-1` == "Who developed the algorithm."~`F-4-2-1`,
                                 `F-4-2` == "Who developed the algorithm."~`F-4-2-2`,
                                 `F-4-3` == "Who developed the algorithm."~`F-4-2-3`,
                                 `F-4-4` == "Who developed the algorithm."~`F-4-2-4`,
                                 `F-4-5` == "Who developed the algorithm."~`F-4-2-5`,
                                 `F-4-6` == "Who developed the algorithm."~`F-4-2-6`,
                                 `F-4-7` == "Who developed the algorithm."~`F-4-2-7`,
                                 `F-4-8` == "Who developed the algorithm."~`F-4-2-8`)) %>%
  select(ResponseId, c4c1, c4c2, c41c, c42c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c4c1:c4c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c4c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c4c1", location11, location12)),
         moe= (ifelse(choiceNum == "c4c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c4c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c4c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c4c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c4c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c4c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c4c1", c41c, c42c)),
         defendant = 4,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant5a <- conjoint2 %>%
  select(ResponseId, c5c1, c5c2, c51c, c52c, starts_with("F-5")) %>%
  mutate(nfactors11 = case_when(`F-5-1` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-1`,
                                `F-5-2` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-2`,
                                `F-5-3` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-3`,
                                `F-5-4` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-4`,
                                `F-5-5` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-5`,
                                `F-5-6` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-6`,
                                `F-5-7` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-7`,
                                `F-5-8` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-8`),
         location11 = case_when(`F-5-1` == "Location from which data to create the algorithm was collected."~`F-5-1-1`,
                                `F-5-2` == "Location from which data to create the algorithm was collected."~`F-5-1-2`,
                                `F-5-3` == "Location from which data to create the algorithm was collected."~`F-5-1-3`,
                                `F-5-4` == "Location from which data to create the algorithm was collected."~`F-5-1-4`,
                                `F-5-5` == "Location from which data to create the algorithm was collected."~`F-5-1-5`,
                                `F-5-6` == "Location from which data to create the algorithm was collected."~`F-5-1-6`,
                                `F-5-7` == "Location from which data to create the algorithm was collected."~`F-5-1-7`,
                                `F-5-8` == "Location from which data to create the algorithm was collected."~`F-5-1-8`),
         moe11 = case_when(`F-5-1` == "Estimated margin of error of probability estimates."~`F-5-1-1`,
                           `F-5-2` == "Estimated margin of error of probability estimates."~`F-5-1-2`,
                           `F-5-3` == "Estimated margin of error of probability estimates."~`F-5-1-3`,
                           `F-5-4` == "Estimated margin of error of probability estimates."~`F-5-1-4`,
                           `F-5-5` == "Estimated margin of error of probability estimates."~`F-5-1-5`,
                           `F-5-6` == "Estimated margin of error of probability estimates."~`F-5-1-6`,
                           `F-5-7` == "Estimated margin of error of probability estimates."~`F-5-1-7`,
                           `F-5-8` == "Estimated margin of error of probability estimates."~`F-5-1-8`),
         weights11 = case_when(`F-5-1` == "Amount of weight given to different factors."~`F-5-1-1`,
                               `F-5-2` == "Amount of weight given to different factors."~`F-5-1-2`,
                               `F-5-3` == "Amount of weight given to different factors."~`F-5-1-3`,
                               `F-5-4` == "Amount of weight given to different factors."~`F-5-1-4`,
                               `F-5-5` == "Amount of weight given to different factors."~`F-5-1-5`,
                               `F-5-6` == "Amount of weight given to different factors."~`F-5-1-6`,
                               `F-5-7` == "Amount of weight given to different factors."~`F-5-1-7`,
                               `F-5-8` == "Amount of weight given to different factors."~`F-5-1-8`),
         accuracy11 = case_when(`F-5-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-1`,
                                `F-5-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-2`,
                                `F-5-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-3`,
                                `F-5-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-4`,
                                `F-5-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-5`,
                                `F-5-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-6`,
                                `F-5-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-7`,
                                `F-5-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-8`),
         human11 = case_when(`F-5-1` == "Human involvement in final estimate (if any)."~`F-5-1-1`,
                             `F-5-2` == "Human involvement in final estimate (if any)."~`F-5-1-2`,
                             `F-5-3` == "Human involvement in final estimate (if any)."~`F-5-1-3`,
                             `F-5-4` == "Human involvement in final estimate (if any)."~`F-5-1-4`,
                             `F-5-5` == "Human involvement in final estimate (if any)."~`F-5-1-5`,
                             `F-5-6` == "Human involvement in final estimate (if any)."~`F-5-1-6`,
                             `F-5-7` == "Human involvement in final estimate (if any)."~`F-5-1-7`,
                             `F-5-8` == "Human involvement in final estimate (if any)."~`F-5-1-8`),
         datasize11 = case_when(`F-5-1` == "Number of cases used to create the algorithm."~`F-5-1-1`,
                                `F-5-2` == "Number of cases used to create the algorithm."~`F-5-1-2`,
                                `F-5-3` == "Number of cases used to create the algorithm."~`F-5-1-3`,
                                `F-5-4` == "Number of cases used to create the algorithm."~`F-5-1-4`,
                                `F-5-5` == "Number of cases used to create the algorithm."~`F-5-1-5`,
                                `F-5-6` == "Number of cases used to create the algorithm."~`F-5-1-6`,
                                `F-5-7` == "Number of cases used to create the algorithm."~`F-5-1-7`,
                                `F-5-8` == "Number of cases used to create the algorithm."~`F-5-1-8`),
         developer11 = case_when(`F-5-1` == "Who developed the algorithm."~`F-5-1-1`,
                                 `F-5-2` == "Who developed the algorithm."~`F-5-1-2`,
                                 `F-5-3` == "Who developed the algorithm."~`F-5-1-3`,
                                 `F-5-4` == "Who developed the algorithm."~`F-5-1-4`,
                                 `F-5-5` == "Who developed the algorithm."~`F-5-1-5`,
                                 `F-5-6` == "Who developed the algorithm."~`F-5-1-6`,
                                 `F-5-7` == "Who developed the algorithm."~`F-5-1-7`,
                                 `F-5-8` == "Who developed the algorithm."~`F-5-1-8`),
         nfactors12 = case_when(`F-5-1` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-1`,
                                `F-5-2` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-2`,
                                `F-5-3` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-3`,
                                `F-5-4` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-4`,
                                `F-5-5` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-5`,
                                `F-5-6` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-6`,
                                `F-5-7` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-7`,
                                `F-5-8` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-8`),
         location12 = case_when(`F-5-1` == "Location from which data to create the algorithm was collected."~`F-5-2-1`,
                                `F-5-2` == "Location from which data to create the algorithm was collected."~`F-5-2-2`,
                                `F-5-3` == "Location from which data to create the algorithm was collected."~`F-5-2-3`,
                                `F-5-4` == "Location from which data to create the algorithm was collected."~`F-5-2-4`,
                                `F-5-5` == "Location from which data to create the algorithm was collected."~`F-5-2-5`,
                                `F-5-6` == "Location from which data to create the algorithm was collected."~`F-5-2-6`,
                                `F-5-7` == "Location from which data to create the algorithm was collected."~`F-5-2-7`,
                                `F-5-8` == "Location from which data to create the algorithm was collected."~`F-5-2-8`),
         moe12 = case_when(`F-5-1` == "Estimated margin of error of probability estimates."~`F-5-2-1`,
                           `F-5-2` == "Estimated margin of error of probability estimates."~`F-5-2-2`,
                           `F-5-3` == "Estimated margin of error of probability estimates."~`F-5-2-3`,
                           `F-5-4` == "Estimated margin of error of probability estimates."~`F-5-2-4`,
                           `F-5-5` == "Estimated margin of error of probability estimates."~`F-5-2-5`,
                           `F-5-6` == "Estimated margin of error of probability estimates."~`F-5-2-6`,
                           `F-5-7` == "Estimated margin of error of probability estimates."~`F-5-2-7`,
                           `F-5-8` == "Estimated margin of error of probability estimates."~`F-5-2-8`),
         weights12 = case_when(`F-5-1` == "Amount of weight given to different factors."~`F-5-2-1`,
                               `F-5-2` == "Amount of weight given to different factors."~`F-5-2-2`,
                               `F-5-3` == "Amount of weight given to different factors."~`F-5-2-3`,
                               `F-5-4` == "Amount of weight given to different factors."~`F-5-2-4`,
                               `F-5-5` == "Amount of weight given to different factors."~`F-5-2-5`,
                               `F-5-6` == "Amount of weight given to different factors."~`F-5-2-6`,
                               `F-5-7` == "Amount of weight given to different factors."~`F-5-2-7`,
                               `F-5-8` == "Amount of weight given to different factors."~`F-5-2-8`),
         accuracy12 = case_when(`F-5-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-1`,
                                `F-5-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-2`,
                                `F-5-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-3`,
                                `F-5-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-4`,
                                `F-5-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-5`,
                                `F-5-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-6`,
                                `F-5-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-7`,
                                `F-5-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-8`),
         human12 = case_when(`F-5-1` == "Human involvement in final estimate (if any)."~`F-5-2-1`,
                             `F-5-2` == "Human involvement in final estimate (if any)."~`F-5-2-2`,
                             `F-5-3` == "Human involvement in final estimate (if any)."~`F-5-2-3`,
                             `F-5-4` == "Human involvement in final estimate (if any)."~`F-5-2-4`,
                             `F-5-5` == "Human involvement in final estimate (if any)."~`F-5-2-5`,
                             `F-5-6` == "Human involvement in final estimate (if any)."~`F-5-2-6`,
                             `F-5-7` == "Human involvement in final estimate (if any)."~`F-5-2-7`,
                             `F-5-8` == "Human involvement in final estimate (if any)."~`F-5-2-8`),
         datasize12 = case_when(`F-5-1` == "Number of cases used to create the algorithm."~`F-5-2-1`,
                                `F-5-2` == "Number of cases used to create the algorithm."~`F-5-2-2`,
                                `F-5-3` == "Number of cases used to create the algorithm."~`F-5-2-3`,
                                `F-5-4` == "Number of cases used to create the algorithm."~`F-5-2-4`,
                                `F-5-5` == "Number of cases used to create the algorithm."~`F-5-2-5`,
                                `F-5-6` == "Number of cases used to create the algorithm."~`F-5-2-6`,
                                `F-5-7` == "Number of cases used to create the algorithm."~`F-5-2-7`,
                                `F-5-8` == "Number of cases used to create the algorithm."~`F-5-2-8`),
         developer12 = case_when(`F-5-1` == "Who developed the algorithm."~`F-5-2-1`,
                                 `F-5-2` == "Who developed the algorithm."~`F-5-2-2`,
                                 `F-5-3` == "Who developed the algorithm."~`F-5-2-3`,
                                 `F-5-4` == "Who developed the algorithm."~`F-5-2-4`,
                                 `F-5-5` == "Who developed the algorithm."~`F-5-2-5`,
                                 `F-5-6` == "Who developed the algorithm."~`F-5-2-6`,
                                 `F-5-7` == "Who developed the algorithm."~`F-5-2-7`,
                                 `F-5-8` == "Who developed the algorithm."~`F-5-2-8`)) %>%
  select(ResponseId, c5c1, c5c2, c51c, c52c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c5c1:c5c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c5c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c5c1", location11, location12)),
         moe= (ifelse(choiceNum == "c5c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c5c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c5c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c5c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c5c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c5c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c5c1", c51c, c52c)),
         defendant = 5,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant1b <- conjoint3 %>%
  select(ResponseId, c1c1, c1c2, c11c, c12c, starts_with("F-1")) %>%
  mutate(nfactors11 = case_when(`F-1-1` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-1`,
                                `F-1-2` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-2`,
                                `F-1-3` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-3`,
                                `F-1-4` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-4`,
                                `F-1-5` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-5`,
                                `F-1-6` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-6`,
                                `F-1-7` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-7`,
                                `F-1-8` == "Number of factors the algorithm uses to make a recommendation."~`F-1-1-8`),
         location11 = case_when(`F-1-1` == "Location from which data to create the algorithm was collected."~`F-1-1-1`,
                                `F-1-2` == "Location from which data to create the algorithm was collected."~`F-1-1-2`,
                                `F-1-3` == "Location from which data to create the algorithm was collected."~`F-1-1-3`,
                                `F-1-4` == "Location from which data to create the algorithm was collected."~`F-1-1-4`,
                                `F-1-5` == "Location from which data to create the algorithm was collected."~`F-1-1-5`,
                                `F-1-6` == "Location from which data to create the algorithm was collected."~`F-1-1-6`,
                                `F-1-7` == "Location from which data to create the algorithm was collected."~`F-1-1-7`,
                                `F-1-8` == "Location from which data to create the algorithm was collected."~`F-1-1-8`),
         moe11 = case_when(`F-1-1` == "Estimated margin of error of probability estimates."~`F-1-1-1`,
                           `F-1-2` == "Estimated margin of error of probability estimates."~`F-1-1-2`,
                           `F-1-3` == "Estimated margin of error of probability estimates."~`F-1-1-3`,
                           `F-1-4` == "Estimated margin of error of probability estimates."~`F-1-1-4`,
                           `F-1-5` == "Estimated margin of error of probability estimates."~`F-1-1-5`,
                           `F-1-6` == "Estimated margin of error of probability estimates."~`F-1-1-6`,
                           `F-1-7` == "Estimated margin of error of probability estimates."~`F-1-1-7`,
                           `F-1-8` == "Estimated margin of error of probability estimates."~`F-1-1-8`),
         weights11 = case_when(`F-1-1` == "Amount of weight given to different factors."~`F-1-1-1`,
                               `F-1-2` == "Amount of weight given to different factors."~`F-1-1-2`,
                               `F-1-3` == "Amount of weight given to different factors."~`F-1-1-3`,
                               `F-1-4` == "Amount of weight given to different factors."~`F-1-1-4`,
                               `F-1-5` == "Amount of weight given to different factors."~`F-1-1-5`,
                               `F-1-6` == "Amount of weight given to different factors."~`F-1-1-6`,
                               `F-1-7` == "Amount of weight given to different factors."~`F-1-1-7`,
                               `F-1-8` == "Amount of weight given to different factors."~`F-1-1-8`),
         accuracy11 = case_when(`F-1-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-1`,
                                `F-1-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-2`,
                                `F-1-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-3`,
                                `F-1-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-4`,
                                `F-1-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-5`,
                                `F-1-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-6`,
                                `F-1-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-7`,
                                `F-1-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-1-8`),
         human11 = case_when(`F-1-1` == "Human involvement in final estimate (if any)."~`F-1-1-1`,
                             `F-1-2` == "Human involvement in final estimate (if any)."~`F-1-1-2`,
                             `F-1-3` == "Human involvement in final estimate (if any)."~`F-1-1-3`,
                             `F-1-4` == "Human involvement in final estimate (if any)."~`F-1-1-4`,
                             `F-1-5` == "Human involvement in final estimate (if any)."~`F-1-1-5`,
                             `F-1-6` == "Human involvement in final estimate (if any)."~`F-1-1-6`,
                             `F-1-7` == "Human involvement in final estimate (if any)."~`F-1-1-7`,
                             `F-1-8` == "Human involvement in final estimate (if any)."~`F-1-1-8`),
         datasize11 = case_when(`F-1-1` == "Number of cases used to create the algorithm."~`F-1-1-1`,
                                `F-1-2` == "Number of cases used to create the algorithm."~`F-1-1-2`,
                                `F-1-3` == "Number of cases used to create the algorithm."~`F-1-1-3`,
                                `F-1-4` == "Number of cases used to create the algorithm."~`F-1-1-4`,
                                `F-1-5` == "Number of cases used to create the algorithm."~`F-1-1-5`,
                                `F-1-6` == "Number of cases used to create the algorithm."~`F-1-1-6`,
                                `F-1-7` == "Number of cases used to create the algorithm."~`F-1-1-7`,
                                `F-1-8` == "Number of cases used to create the algorithm."~`F-1-1-8`),
         developer11 = case_when(`F-1-1` == "Who developed the algorithm."~`F-1-1-1`,
                                 `F-1-2` == "Who developed the algorithm."~`F-1-1-2`,
                                 `F-1-3` == "Who developed the algorithm."~`F-1-1-3`,
                                 `F-1-4` == "Who developed the algorithm."~`F-1-1-4`,
                                 `F-1-5` == "Who developed the algorithm."~`F-1-1-5`,
                                 `F-1-6` == "Who developed the algorithm."~`F-1-1-6`,
                                 `F-1-7` == "Who developed the algorithm."~`F-1-1-7`,
                                 `F-1-8` == "Who developed the algorithm."~`F-1-1-8`),
         nfactors12 = case_when(`F-1-1` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-1`,
                                `F-1-2` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-2`,
                                `F-1-3` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-3`,
                                `F-1-4` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-4`,
                                `F-1-5` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-5`,
                                `F-1-6` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-6`,
                                `F-1-7` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-7`,
                                `F-1-8` == "Number of factors the algorithm uses to make a recommendation."~`F-1-2-8`),
         location12 = case_when(`F-1-1` == "Location from which data to create the algorithm was collected."~`F-1-2-1`,
                                `F-1-2` == "Location from which data to create the algorithm was collected."~`F-1-2-2`,
                                `F-1-3` == "Location from which data to create the algorithm was collected."~`F-1-2-3`,
                                `F-1-4` == "Location from which data to create the algorithm was collected."~`F-1-2-4`,
                                `F-1-5` == "Location from which data to create the algorithm was collected."~`F-1-2-5`,
                                `F-1-6` == "Location from which data to create the algorithm was collected."~`F-1-2-6`,
                                `F-1-7` == "Location from which data to create the algorithm was collected."~`F-1-2-7`,
                                `F-1-8` == "Location from which data to create the algorithm was collected."~`F-1-2-8`),
         moe12 = case_when(`F-1-1` == "Estimated margin of error of probability estimates."~`F-1-2-1`,
                           `F-1-2` == "Estimated margin of error of probability estimates."~`F-1-2-2`,
                           `F-1-3` == "Estimated margin of error of probability estimates."~`F-1-2-3`,
                           `F-1-4` == "Estimated margin of error of probability estimates."~`F-1-2-4`,
                           `F-1-5` == "Estimated margin of error of probability estimates."~`F-1-2-5`,
                           `F-1-6` == "Estimated margin of error of probability estimates."~`F-1-2-6`,
                           `F-1-7` == "Estimated margin of error of probability estimates."~`F-1-2-7`,
                           `F-1-8` == "Estimated margin of error of probability estimates."~`F-1-2-8`),
         weights12 = case_when(`F-1-1` == "Amount of weight given to different factors."~`F-1-2-1`,
                               `F-1-2` == "Amount of weight given to different factors."~`F-1-2-2`,
                               `F-1-3` == "Amount of weight given to different factors."~`F-1-2-3`,
                               `F-1-4` == "Amount of weight given to different factors."~`F-1-2-4`,
                               `F-1-5` == "Amount of weight given to different factors."~`F-1-2-5`,
                               `F-1-6` == "Amount of weight given to different factors."~`F-1-2-6`,
                               `F-1-7` == "Amount of weight given to different factors."~`F-1-2-7`,
                               `F-1-8` == "Amount of weight given to different factors."~`F-1-2-8`),
         accuracy12 = case_when(`F-1-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-1`,
                                `F-1-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-2`,
                                `F-1-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-3`,
                                `F-1-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-4`,
                                `F-1-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-5`,
                                `F-1-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-6`,
                                `F-1-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-7`,
                                `F-1-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-1-2-8`),
         human12 = case_when(`F-1-1` == "Human involvement in final estimate (if any)."~`F-1-2-1`,
                             `F-1-2` == "Human involvement in final estimate (if any)."~`F-1-2-2`,
                             `F-1-3` == "Human involvement in final estimate (if any)."~`F-1-2-3`,
                             `F-1-4` == "Human involvement in final estimate (if any)."~`F-1-2-4`,
                             `F-1-5` == "Human involvement in final estimate (if any)."~`F-1-2-5`,
                             `F-1-6` == "Human involvement in final estimate (if any)."~`F-1-2-6`,
                             `F-1-7` == "Human involvement in final estimate (if any)."~`F-1-2-7`,
                             `F-1-8` == "Human involvement in final estimate (if any)."~`F-1-2-8`),
         datasize12 = case_when(`F-1-1` == "Number of cases used to create the algorithm."~`F-1-2-1`,
                                `F-1-2` == "Number of cases used to create the algorithm."~`F-1-2-2`,
                                `F-1-3` == "Number of cases used to create the algorithm."~`F-1-2-3`,
                                `F-1-4` == "Number of cases used to create the algorithm."~`F-1-2-4`,
                                `F-1-5` == "Number of cases used to create the algorithm."~`F-1-2-5`,
                                `F-1-6` == "Number of cases used to create the algorithm."~`F-1-2-6`,
                                `F-1-7` == "Number of cases used to create the algorithm."~`F-1-2-7`,
                                `F-1-8` == "Number of cases used to create the algorithm."~`F-1-2-8`),
         developer12 = case_when(`F-1-1` == "Who developed the algorithm."~`F-1-2-1`,
                                 `F-1-2` == "Who developed the algorithm."~`F-1-2-2`,
                                 `F-1-3` == "Who developed the algorithm."~`F-1-2-3`,
                                 `F-1-4` == "Who developed the algorithm."~`F-1-2-4`,
                                 `F-1-5` == "Who developed the algorithm."~`F-1-2-5`,
                                 `F-1-6` == "Who developed the algorithm."~`F-1-2-6`,
                                 `F-1-7` == "Who developed the algorithm."~`F-1-2-7`,
                                 `F-1-8` == "Who developed the algorithm."~`F-1-2-8`)) %>%
  select(ResponseId, c1c1, c1c2, c11c, c12c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c1c1:c1c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c1c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c1c1", location11, location12)),
         moe= (ifelse(choiceNum == "c1c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c1c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c1c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c1c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c1c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c1c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c1c1", c11c, c12c)),
         defendant = 1,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant2b <- conjoint3 %>%
  select(ResponseId, c2c1, c2c2, c21c, c22c, starts_with("F-2")) %>%
  mutate(nfactors11 = case_when(`F-2-1` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-1`,
                                `F-2-2` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-2`,
                                `F-2-3` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-3`,
                                `F-2-4` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-4`,
                                `F-2-5` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-5`,
                                `F-2-6` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-6`,
                                `F-2-7` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-7`,
                                `F-2-8` == "Number of factors the algorithm uses to make a recommendation."~`F-2-1-8`),
         location11 = case_when(`F-2-1` == "Location from which data to create the algorithm was collected."~`F-2-1-1`,
                                `F-2-2` == "Location from which data to create the algorithm was collected."~`F-2-1-2`,
                                `F-2-3` == "Location from which data to create the algorithm was collected."~`F-2-1-3`,
                                `F-2-4` == "Location from which data to create the algorithm was collected."~`F-2-1-4`,
                                `F-2-5` == "Location from which data to create the algorithm was collected."~`F-2-1-5`,
                                `F-2-6` == "Location from which data to create the algorithm was collected."~`F-2-1-6`,
                                `F-2-7` == "Location from which data to create the algorithm was collected."~`F-2-1-7`,
                                `F-2-8` == "Location from which data to create the algorithm was collected."~`F-2-1-8`),
         moe11 = case_when(`F-2-1` == "Estimated margin of error of probability estimates."~`F-2-1-1`,
                           `F-2-2` == "Estimated margin of error of probability estimates."~`F-2-1-2`,
                           `F-2-3` == "Estimated margin of error of probability estimates."~`F-2-1-3`,
                           `F-2-4` == "Estimated margin of error of probability estimates."~`F-2-1-4`,
                           `F-2-5` == "Estimated margin of error of probability estimates."~`F-2-1-5`,
                           `F-2-6` == "Estimated margin of error of probability estimates."~`F-2-1-6`,
                           `F-2-7` == "Estimated margin of error of probability estimates."~`F-2-1-7`,
                           `F-2-8` == "Estimated margin of error of probability estimates."~`F-2-1-8`),
         weights11 = case_when(`F-2-1` == "Amount of weight given to different factors."~`F-2-1-1`,
                               `F-2-2` == "Amount of weight given to different factors."~`F-2-1-2`,
                               `F-2-3` == "Amount of weight given to different factors."~`F-2-1-3`,
                               `F-2-4` == "Amount of weight given to different factors."~`F-2-1-4`,
                               `F-2-5` == "Amount of weight given to different factors."~`F-2-1-5`,
                               `F-2-6` == "Amount of weight given to different factors."~`F-2-1-6`,
                               `F-2-7` == "Amount of weight given to different factors."~`F-2-1-7`,
                               `F-2-8` == "Amount of weight given to different factors."~`F-2-1-8`),
         accuracy11 = case_when(`F-2-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-1`,
                                `F-2-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-2`,
                                `F-2-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-3`,
                                `F-2-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-4`,
                                `F-2-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-5`,
                                `F-2-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-6`,
                                `F-2-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-7`,
                                `F-2-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-1-8`),
         human11 = case_when(`F-2-1` == "Human involvement in final estimate (if any)."~`F-2-1-1`,
                             `F-2-2` == "Human involvement in final estimate (if any)."~`F-2-1-2`,
                             `F-2-3` == "Human involvement in final estimate (if any)."~`F-2-1-3`,
                             `F-2-4` == "Human involvement in final estimate (if any)."~`F-2-1-4`,
                             `F-2-5` == "Human involvement in final estimate (if any)."~`F-2-1-5`,
                             `F-2-6` == "Human involvement in final estimate (if any)."~`F-2-1-6`,
                             `F-2-7` == "Human involvement in final estimate (if any)."~`F-2-1-7`,
                             `F-2-8` == "Human involvement in final estimate (if any)."~`F-2-1-8`),
         datasize11 = case_when(`F-2-1` == "Number of cases used to create the algorithm."~`F-2-1-1`,
                                `F-2-2` == "Number of cases used to create the algorithm."~`F-2-1-2`,
                                `F-2-3` == "Number of cases used to create the algorithm."~`F-2-1-3`,
                                `F-2-4` == "Number of cases used to create the algorithm."~`F-2-1-4`,
                                `F-2-5` == "Number of cases used to create the algorithm."~`F-2-1-5`,
                                `F-2-6` == "Number of cases used to create the algorithm."~`F-2-1-6`,
                                `F-2-7` == "Number of cases used to create the algorithm."~`F-2-1-7`,
                                `F-2-8` == "Number of cases used to create the algorithm."~`F-2-1-8`),
         developer11 = case_when(`F-2-1` == "Who developed the algorithm."~`F-2-1-1`,
                                 `F-2-2` == "Who developed the algorithm."~`F-2-1-2`,
                                 `F-2-3` == "Who developed the algorithm."~`F-2-1-3`,
                                 `F-2-4` == "Who developed the algorithm."~`F-2-1-4`,
                                 `F-2-5` == "Who developed the algorithm."~`F-2-1-5`,
                                 `F-2-6` == "Who developed the algorithm."~`F-2-1-6`,
                                 `F-2-7` == "Who developed the algorithm."~`F-2-1-7`,
                                 `F-2-8` == "Who developed the algorithm."~`F-2-1-8`),
         nfactors12 = case_when(`F-2-1` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-1`,
                                `F-2-2` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-2`,
                                `F-2-3` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-3`,
                                `F-2-4` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-4`,
                                `F-2-5` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-5`,
                                `F-2-6` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-6`,
                                `F-2-7` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-7`,
                                `F-2-8` == "Number of factors the algorithm uses to make a recommendation."~`F-2-2-8`),
         location12 = case_when(`F-2-1` == "Location from which data to create the algorithm was collected."~`F-2-2-1`,
                                `F-2-2` == "Location from which data to create the algorithm was collected."~`F-2-2-2`,
                                `F-2-3` == "Location from which data to create the algorithm was collected."~`F-2-2-3`,
                                `F-2-4` == "Location from which data to create the algorithm was collected."~`F-2-2-4`,
                                `F-2-5` == "Location from which data to create the algorithm was collected."~`F-2-2-5`,
                                `F-2-6` == "Location from which data to create the algorithm was collected."~`F-2-2-6`,
                                `F-2-7` == "Location from which data to create the algorithm was collected."~`F-2-2-7`,
                                `F-2-8` == "Location from which data to create the algorithm was collected."~`F-2-2-8`),
         moe12 = case_when(`F-2-1` == "Estimated margin of error of probability estimates."~`F-2-2-1`,
                           `F-2-2` == "Estimated margin of error of probability estimates."~`F-2-2-2`,
                           `F-2-3` == "Estimated margin of error of probability estimates."~`F-2-2-3`,
                           `F-2-4` == "Estimated margin of error of probability estimates."~`F-2-2-4`,
                           `F-2-5` == "Estimated margin of error of probability estimates."~`F-2-2-5`,
                           `F-2-6` == "Estimated margin of error of probability estimates."~`F-2-2-6`,
                           `F-2-7` == "Estimated margin of error of probability estimates."~`F-2-2-7`,
                           `F-2-8` == "Estimated margin of error of probability estimates."~`F-2-2-8`),
         weights12 = case_when(`F-2-1` == "Amount of weight given to different factors."~`F-2-2-1`,
                               `F-2-2` == "Amount of weight given to different factors."~`F-2-2-2`,
                               `F-2-3` == "Amount of weight given to different factors."~`F-2-2-3`,
                               `F-2-4` == "Amount of weight given to different factors."~`F-2-2-4`,
                               `F-2-5` == "Amount of weight given to different factors."~`F-2-2-5`,
                               `F-2-6` == "Amount of weight given to different factors."~`F-2-2-6`,
                               `F-2-7` == "Amount of weight given to different factors."~`F-2-2-7`,
                               `F-2-8` == "Amount of weight given to different factors."~`F-2-2-8`),
         accuracy12 = case_when(`F-2-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-1`,
                                `F-2-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-2`,
                                `F-2-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-3`,
                                `F-2-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-4`,
                                `F-2-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-5`,
                                `F-2-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-6`,
                                `F-2-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-7`,
                                `F-2-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-2-2-8`),
         human12 = case_when(`F-2-1` == "Human involvement in final estimate (if any)."~`F-2-2-1`,
                             `F-2-2` == "Human involvement in final estimate (if any)."~`F-2-2-2`,
                             `F-2-3` == "Human involvement in final estimate (if any)."~`F-2-2-3`,
                             `F-2-4` == "Human involvement in final estimate (if any)."~`F-2-2-4`,
                             `F-2-5` == "Human involvement in final estimate (if any)."~`F-2-2-5`,
                             `F-2-6` == "Human involvement in final estimate (if any)."~`F-2-2-6`,
                             `F-2-7` == "Human involvement in final estimate (if any)."~`F-2-2-7`,
                             `F-2-8` == "Human involvement in final estimate (if any)."~`F-2-2-8`),
         datasize12 = case_when(`F-2-1` == "Number of cases used to create the algorithm."~`F-2-2-1`,
                                `F-2-2` == "Number of cases used to create the algorithm."~`F-2-2-2`,
                                `F-2-3` == "Number of cases used to create the algorithm."~`F-2-2-3`,
                                `F-2-4` == "Number of cases used to create the algorithm."~`F-2-2-4`,
                                `F-2-5` == "Number of cases used to create the algorithm."~`F-2-2-5`,
                                `F-2-6` == "Number of cases used to create the algorithm."~`F-2-2-6`,
                                `F-2-7` == "Number of cases used to create the algorithm."~`F-2-2-7`,
                                `F-2-8` == "Number of cases used to create the algorithm."~`F-2-2-8`),
         developer12 = case_when(`F-2-1` == "Who developed the algorithm."~`F-2-2-1`,
                                 `F-2-2` == "Who developed the algorithm."~`F-2-2-2`,
                                 `F-2-3` == "Who developed the algorithm."~`F-2-2-3`,
                                 `F-2-4` == "Who developed the algorithm."~`F-2-2-4`,
                                 `F-2-5` == "Who developed the algorithm."~`F-2-2-5`,
                                 `F-2-6` == "Who developed the algorithm."~`F-2-2-6`,
                                 `F-2-7` == "Who developed the algorithm."~`F-2-2-7`,
                                 `F-2-8` == "Who developed the algorithm."~`F-2-2-8`)) %>%
  select(ResponseId, c2c1, c2c2, c21c, c22c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c2c1:c2c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c2c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c2c1", location11, location12)),
         moe= (ifelse(choiceNum == "c2c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c2c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c2c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c2c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c2c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c2c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c2c1", c21c, c22c)),
         defendant = 2,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant3b <- conjoint3 %>%
  select(ResponseId, c3c1, c3c2, c31c, c32c, starts_with("F-3")) %>%
  mutate(nfactors11 = case_when(`F-3-1` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-1`,
                                `F-3-2` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-2`,
                                `F-3-3` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-3`,
                                `F-3-4` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-4`,
                                `F-3-5` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-5`,
                                `F-3-6` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-6`,
                                `F-3-7` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-7`,
                                `F-3-8` == "Number of factors the algorithm uses to make a recommendation."~`F-3-1-8`),
         location11 = case_when(`F-3-1` == "Location from which data to create the algorithm was collected."~`F-3-1-1`,
                                `F-3-2` == "Location from which data to create the algorithm was collected."~`F-3-1-2`,
                                `F-3-3` == "Location from which data to create the algorithm was collected."~`F-3-1-3`,
                                `F-3-4` == "Location from which data to create the algorithm was collected."~`F-3-1-4`,
                                `F-3-5` == "Location from which data to create the algorithm was collected."~`F-3-1-5`,
                                `F-3-6` == "Location from which data to create the algorithm was collected."~`F-3-1-6`,
                                `F-3-7` == "Location from which data to create the algorithm was collected."~`F-3-1-7`,
                                `F-3-8` == "Location from which data to create the algorithm was collected."~`F-3-1-8`),
         moe11 = case_when(`F-3-1` == "Estimated margin of error of probability estimates."~`F-3-1-1`,
                           `F-3-2` == "Estimated margin of error of probability estimates."~`F-3-1-2`,
                           `F-3-3` == "Estimated margin of error of probability estimates."~`F-3-1-3`,
                           `F-3-4` == "Estimated margin of error of probability estimates."~`F-3-1-4`,
                           `F-3-5` == "Estimated margin of error of probability estimates."~`F-3-1-5`,
                           `F-3-6` == "Estimated margin of error of probability estimates."~`F-3-1-6`,
                           `F-3-7` == "Estimated margin of error of probability estimates."~`F-3-1-7`,
                           `F-3-8` == "Estimated margin of error of probability estimates."~`F-3-1-8`),
         weights11 = case_when(`F-3-1` == "Amount of weight given to different factors."~`F-3-1-1`,
                               `F-3-2` == "Amount of weight given to different factors."~`F-3-1-2`,
                               `F-3-3` == "Amount of weight given to different factors."~`F-3-1-3`,
                               `F-3-4` == "Amount of weight given to different factors."~`F-3-1-4`,
                               `F-3-5` == "Amount of weight given to different factors."~`F-3-1-5`,
                               `F-3-6` == "Amount of weight given to different factors."~`F-3-1-6`,
                               `F-3-7` == "Amount of weight given to different factors."~`F-3-1-7`,
                               `F-3-8` == "Amount of weight given to different factors."~`F-3-1-8`),
         accuracy11 = case_when(`F-3-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-1`,
                                `F-3-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-2`,
                                `F-3-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-3`,
                                `F-3-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-4`,
                                `F-3-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-5`,
                                `F-3-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-6`,
                                `F-3-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-7`,
                                `F-3-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-1-8`),
         human11 = case_when(`F-3-1` == "Human involvement in final estimate (if any)."~`F-3-1-1`,
                             `F-3-2` == "Human involvement in final estimate (if any)."~`F-3-1-2`,
                             `F-3-3` == "Human involvement in final estimate (if any)."~`F-3-1-3`,
                             `F-3-4` == "Human involvement in final estimate (if any)."~`F-3-1-4`,
                             `F-3-5` == "Human involvement in final estimate (if any)."~`F-3-1-5`,
                             `F-3-6` == "Human involvement in final estimate (if any)."~`F-3-1-6`,
                             `F-3-7` == "Human involvement in final estimate (if any)."~`F-3-1-7`,
                             `F-3-8` == "Human involvement in final estimate (if any)."~`F-3-1-8`),
         datasize11 = case_when(`F-3-1` == "Number of cases used to create the algorithm."~`F-3-1-1`,
                                `F-3-2` == "Number of cases used to create the algorithm."~`F-3-1-2`,
                                `F-3-3` == "Number of cases used to create the algorithm."~`F-3-1-3`,
                                `F-3-4` == "Number of cases used to create the algorithm."~`F-3-1-4`,
                                `F-3-5` == "Number of cases used to create the algorithm."~`F-3-1-5`,
                                `F-3-6` == "Number of cases used to create the algorithm."~`F-3-1-6`,
                                `F-3-7` == "Number of cases used to create the algorithm."~`F-3-1-7`,
                                `F-3-8` == "Number of cases used to create the algorithm."~`F-3-1-8`),
         developer11 = case_when(`F-3-1` == "Who developed the algorithm."~`F-3-1-1`,
                                 `F-3-2` == "Who developed the algorithm."~`F-3-1-2`,
                                 `F-3-3` == "Who developed the algorithm."~`F-3-1-3`,
                                 `F-3-4` == "Who developed the algorithm."~`F-3-1-4`,
                                 `F-3-5` == "Who developed the algorithm."~`F-3-1-5`,
                                 `F-3-6` == "Who developed the algorithm."~`F-3-1-6`,
                                 `F-3-7` == "Who developed the algorithm."~`F-3-1-7`,
                                 `F-3-8` == "Who developed the algorithm."~`F-3-1-8`),
         nfactors12 = case_when(`F-3-1` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-1`,
                                `F-3-2` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-2`,
                                `F-3-3` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-3`,
                                `F-3-4` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-4`,
                                `F-3-5` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-5`,
                                `F-3-6` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-6`,
                                `F-3-7` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-7`,
                                `F-3-8` == "Number of factors the algorithm uses to make a recommendation."~`F-3-2-8`),
         location12 = case_when(`F-3-1` == "Location from which data to create the algorithm was collected."~`F-3-2-1`,
                                `F-3-2` == "Location from which data to create the algorithm was collected."~`F-3-2-2`,
                                `F-3-3` == "Location from which data to create the algorithm was collected."~`F-3-2-3`,
                                `F-3-4` == "Location from which data to create the algorithm was collected."~`F-3-2-4`,
                                `F-3-5` == "Location from which data to create the algorithm was collected."~`F-3-2-5`,
                                `F-3-6` == "Location from which data to create the algorithm was collected."~`F-3-2-6`,
                                `F-3-7` == "Location from which data to create the algorithm was collected."~`F-3-2-7`,
                                `F-3-8` == "Location from which data to create the algorithm was collected."~`F-3-2-8`),
         moe12 = case_when(`F-3-1` == "Estimated margin of error of probability estimates."~`F-3-2-1`,
                           `F-3-2` == "Estimated margin of error of probability estimates."~`F-3-2-2`,
                           `F-3-3` == "Estimated margin of error of probability estimates."~`F-3-2-3`,
                           `F-3-4` == "Estimated margin of error of probability estimates."~`F-3-2-4`,
                           `F-3-5` == "Estimated margin of error of probability estimates."~`F-3-2-5`,
                           `F-3-6` == "Estimated margin of error of probability estimates."~`F-3-2-6`,
                           `F-3-7` == "Estimated margin of error of probability estimates."~`F-3-2-7`,
                           `F-3-8` == "Estimated margin of error of probability estimates."~`F-3-2-8`),
         weights12 = case_when(`F-3-1` == "Amount of weight given to different factors."~`F-3-2-1`,
                               `F-3-2` == "Amount of weight given to different factors."~`F-3-2-2`,
                               `F-3-3` == "Amount of weight given to different factors."~`F-3-2-3`,
                               `F-3-4` == "Amount of weight given to different factors."~`F-3-2-4`,
                               `F-3-5` == "Amount of weight given to different factors."~`F-3-2-5`,
                               `F-3-6` == "Amount of weight given to different factors."~`F-3-2-6`,
                               `F-3-7` == "Amount of weight given to different factors."~`F-3-2-7`,
                               `F-3-8` == "Amount of weight given to different factors."~`F-3-2-8`),
         accuracy12 = case_when(`F-3-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-1`,
                                `F-3-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-2`,
                                `F-3-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-3`,
                                `F-3-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-4`,
                                `F-3-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-5`,
                                `F-3-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-6`,
                                `F-3-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-7`,
                                `F-3-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-3-2-8`),
         human12 = case_when(`F-3-1` == "Human involvement in final estimate (if any)."~`F-3-2-1`,
                             `F-3-2` == "Human involvement in final estimate (if any)."~`F-3-2-2`,
                             `F-3-3` == "Human involvement in final estimate (if any)."~`F-3-2-3`,
                             `F-3-4` == "Human involvement in final estimate (if any)."~`F-3-2-4`,
                             `F-3-5` == "Human involvement in final estimate (if any)."~`F-3-2-5`,
                             `F-3-6` == "Human involvement in final estimate (if any)."~`F-3-2-6`,
                             `F-3-7` == "Human involvement in final estimate (if any)."~`F-3-2-7`,
                             `F-3-8` == "Human involvement in final estimate (if any)."~`F-3-2-8`),
         datasize12 = case_when(`F-3-1` == "Number of cases used to create the algorithm."~`F-3-2-1`,
                                `F-3-2` == "Number of cases used to create the algorithm."~`F-3-2-2`,
                                `F-3-3` == "Number of cases used to create the algorithm."~`F-3-2-3`,
                                `F-3-4` == "Number of cases used to create the algorithm."~`F-3-2-4`,
                                `F-3-5` == "Number of cases used to create the algorithm."~`F-3-2-5`,
                                `F-3-6` == "Number of cases used to create the algorithm."~`F-3-2-6`,
                                `F-3-7` == "Number of cases used to create the algorithm."~`F-3-2-7`,
                                `F-3-8` == "Number of cases used to create the algorithm."~`F-3-2-8`),
         developer12 = case_when(`F-3-1` == "Who developed the algorithm."~`F-3-2-1`,
                                 `F-3-2` == "Who developed the algorithm."~`F-3-2-2`,
                                 `F-3-3` == "Who developed the algorithm."~`F-3-2-3`,
                                 `F-3-4` == "Who developed the algorithm."~`F-3-2-4`,
                                 `F-3-5` == "Who developed the algorithm."~`F-3-2-5`,
                                 `F-3-6` == "Who developed the algorithm."~`F-3-2-6`,
                                 `F-3-7` == "Who developed the algorithm."~`F-3-2-7`,
                                 `F-3-8` == "Who developed the algorithm."~`F-3-2-8`)) %>%
  select(ResponseId, c3c1, c3c2, c31c, c32c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c3c1:c3c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c3c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c3c1", location11, location12)),
         moe= (ifelse(choiceNum == "c3c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c3c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c3c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c3c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c3c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c3c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c3c1", c31c, c32c)),
         defendant = 3,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant4b <- conjoint3 %>%
  select(ResponseId, c4c1, c4c2, c41c, c42c, starts_with("F-4")) %>%
  mutate(nfactors11 = case_when(`F-4-1` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-1`,
                                `F-4-2` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-2`,
                                `F-4-3` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-3`,
                                `F-4-4` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-4`,
                                `F-4-5` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-5`,
                                `F-4-6` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-6`,
                                `F-4-7` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-7`,
                                `F-4-8` == "Number of factors the algorithm uses to make a recommendation."~`F-4-1-8`),
         location11 = case_when(`F-4-1` == "Location from which data to create the algorithm was collected."~`F-4-1-1`,
                                `F-4-2` == "Location from which data to create the algorithm was collected."~`F-4-1-2`,
                                `F-4-3` == "Location from which data to create the algorithm was collected."~`F-4-1-3`,
                                `F-4-4` == "Location from which data to create the algorithm was collected."~`F-4-1-4`,
                                `F-4-5` == "Location from which data to create the algorithm was collected."~`F-4-1-5`,
                                `F-4-6` == "Location from which data to create the algorithm was collected."~`F-4-1-6`,
                                `F-4-7` == "Location from which data to create the algorithm was collected."~`F-4-1-7`,
                                `F-4-8` == "Location from which data to create the algorithm was collected."~`F-4-1-8`),
         moe11 = case_when(`F-4-1` == "Estimated margin of error of probability estimates."~`F-4-1-1`,
                           `F-4-2` == "Estimated margin of error of probability estimates."~`F-4-1-2`,
                           `F-4-3` == "Estimated margin of error of probability estimates."~`F-4-1-3`,
                           `F-4-4` == "Estimated margin of error of probability estimates."~`F-4-1-4`,
                           `F-4-5` == "Estimated margin of error of probability estimates."~`F-4-1-5`,
                           `F-4-6` == "Estimated margin of error of probability estimates."~`F-4-1-6`,
                           `F-4-7` == "Estimated margin of error of probability estimates."~`F-4-1-7`,
                           `F-4-8` == "Estimated margin of error of probability estimates."~`F-4-1-8`),
         weights11 = case_when(`F-4-1` == "Amount of weight given to different factors."~`F-4-1-1`,
                               `F-4-2` == "Amount of weight given to different factors."~`F-4-1-2`,
                               `F-4-3` == "Amount of weight given to different factors."~`F-4-1-3`,
                               `F-4-4` == "Amount of weight given to different factors."~`F-4-1-4`,
                               `F-4-5` == "Amount of weight given to different factors."~`F-4-1-5`,
                               `F-4-6` == "Amount of weight given to different factors."~`F-4-1-6`,
                               `F-4-7` == "Amount of weight given to different factors."~`F-4-1-7`,
                               `F-4-8` == "Amount of weight given to different factors."~`F-4-1-8`),
         accuracy11 = case_when(`F-4-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-1`,
                                `F-4-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-2`,
                                `F-4-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-3`,
                                `F-4-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-4`,
                                `F-4-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-5`,
                                `F-4-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-6`,
                                `F-4-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-7`,
                                `F-4-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-1-8`),
         human11 = case_when(`F-4-1` == "Human involvement in final estimate (if any)."~`F-4-1-1`,
                             `F-4-2` == "Human involvement in final estimate (if any)."~`F-4-1-2`,
                             `F-4-3` == "Human involvement in final estimate (if any)."~`F-4-1-3`,
                             `F-4-4` == "Human involvement in final estimate (if any)."~`F-4-1-4`,
                             `F-4-5` == "Human involvement in final estimate (if any)."~`F-4-1-5`,
                             `F-4-6` == "Human involvement in final estimate (if any)."~`F-4-1-6`,
                             `F-4-7` == "Human involvement in final estimate (if any)."~`F-4-1-7`,
                             `F-4-8` == "Human involvement in final estimate (if any)."~`F-4-1-8`),
         datasize11 = case_when(`F-4-1` == "Number of cases used to create the algorithm."~`F-4-1-1`,
                                `F-4-2` == "Number of cases used to create the algorithm."~`F-4-1-2`,
                                `F-4-3` == "Number of cases used to create the algorithm."~`F-4-1-3`,
                                `F-4-4` == "Number of cases used to create the algorithm."~`F-4-1-4`,
                                `F-4-5` == "Number of cases used to create the algorithm."~`F-4-1-5`,
                                `F-4-6` == "Number of cases used to create the algorithm."~`F-4-1-6`,
                                `F-4-7` == "Number of cases used to create the algorithm."~`F-4-1-7`,
                                `F-4-8` == "Number of cases used to create the algorithm."~`F-4-1-8`),
         developer11 = case_when(`F-4-1` == "Who developed the algorithm."~`F-4-1-1`,
                                 `F-4-2` == "Who developed the algorithm."~`F-4-1-2`,
                                 `F-4-3` == "Who developed the algorithm."~`F-4-1-3`,
                                 `F-4-4` == "Who developed the algorithm."~`F-4-1-4`,
                                 `F-4-5` == "Who developed the algorithm."~`F-4-1-5`,
                                 `F-4-6` == "Who developed the algorithm."~`F-4-1-6`,
                                 `F-4-7` == "Who developed the algorithm."~`F-4-1-7`,
                                 `F-4-8` == "Who developed the algorithm."~`F-4-1-8`),
         nfactors12 = case_when(`F-4-1` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-1`,
                                `F-4-2` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-2`,
                                `F-4-3` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-3`,
                                `F-4-4` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-4`,
                                `F-4-5` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-5`,
                                `F-4-6` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-6`,
                                `F-4-7` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-7`,
                                `F-4-8` == "Number of factors the algorithm uses to make a recommendation."~`F-4-2-8`),
         location12 = case_when(`F-4-1` == "Location from which data to create the algorithm was collected."~`F-4-2-1`,
                                `F-4-2` == "Location from which data to create the algorithm was collected."~`F-4-2-2`,
                                `F-4-3` == "Location from which data to create the algorithm was collected."~`F-4-2-3`,
                                `F-4-4` == "Location from which data to create the algorithm was collected."~`F-4-2-4`,
                                `F-4-5` == "Location from which data to create the algorithm was collected."~`F-4-2-5`,
                                `F-4-6` == "Location from which data to create the algorithm was collected."~`F-4-2-6`,
                                `F-4-7` == "Location from which data to create the algorithm was collected."~`F-4-2-7`,
                                `F-4-8` == "Location from which data to create the algorithm was collected."~`F-4-2-8`),
         moe12 = case_when(`F-4-1` == "Estimated margin of error of probability estimates."~`F-4-2-1`,
                           `F-4-2` == "Estimated margin of error of probability estimates."~`F-4-2-2`,
                           `F-4-3` == "Estimated margin of error of probability estimates."~`F-4-2-3`,
                           `F-4-4` == "Estimated margin of error of probability estimates."~`F-4-2-4`,
                           `F-4-5` == "Estimated margin of error of probability estimates."~`F-4-2-5`,
                           `F-4-6` == "Estimated margin of error of probability estimates."~`F-4-2-6`,
                           `F-4-7` == "Estimated margin of error of probability estimates."~`F-4-2-7`,
                           `F-4-8` == "Estimated margin of error of probability estimates."~`F-4-2-8`),
         weights12 = case_when(`F-4-1` == "Amount of weight given to different factors."~`F-4-2-1`,
                               `F-4-2` == "Amount of weight given to different factors."~`F-4-2-2`,
                               `F-4-3` == "Amount of weight given to different factors."~`F-4-2-3`,
                               `F-4-4` == "Amount of weight given to different factors."~`F-4-2-4`,
                               `F-4-5` == "Amount of weight given to different factors."~`F-4-2-5`,
                               `F-4-6` == "Amount of weight given to different factors."~`F-4-2-6`,
                               `F-4-7` == "Amount of weight given to different factors."~`F-4-2-7`,
                               `F-4-8` == "Amount of weight given to different factors."~`F-4-2-8`),
         accuracy12 = case_when(`F-4-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-1`,
                                `F-4-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-2`,
                                `F-4-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-3`,
                                `F-4-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-4`,
                                `F-4-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-5`,
                                `F-4-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-6`,
                                `F-4-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-7`,
                                `F-4-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-4-2-8`),
         human12 = case_when(`F-4-1` == "Human involvement in final estimate (if any)."~`F-4-2-1`,
                             `F-4-2` == "Human involvement in final estimate (if any)."~`F-4-2-2`,
                             `F-4-3` == "Human involvement in final estimate (if any)."~`F-4-2-3`,
                             `F-4-4` == "Human involvement in final estimate (if any)."~`F-4-2-4`,
                             `F-4-5` == "Human involvement in final estimate (if any)."~`F-4-2-5`,
                             `F-4-6` == "Human involvement in final estimate (if any)."~`F-4-2-6`,
                             `F-4-7` == "Human involvement in final estimate (if any)."~`F-4-2-7`,
                             `F-4-8` == "Human involvement in final estimate (if any)."~`F-4-2-8`),
         datasize12 = case_when(`F-4-1` == "Number of cases used to create the algorithm."~`F-4-2-1`,
                                `F-4-2` == "Number of cases used to create the algorithm."~`F-4-2-2`,
                                `F-4-3` == "Number of cases used to create the algorithm."~`F-4-2-3`,
                                `F-4-4` == "Number of cases used to create the algorithm."~`F-4-2-4`,
                                `F-4-5` == "Number of cases used to create the algorithm."~`F-4-2-5`,
                                `F-4-6` == "Number of cases used to create the algorithm."~`F-4-2-6`,
                                `F-4-7` == "Number of cases used to create the algorithm."~`F-4-2-7`,
                                `F-4-8` == "Number of cases used to create the algorithm."~`F-4-2-8`),
         developer12 = case_when(`F-4-1` == "Who developed the algorithm."~`F-4-2-1`,
                                 `F-4-2` == "Who developed the algorithm."~`F-4-2-2`,
                                 `F-4-3` == "Who developed the algorithm."~`F-4-2-3`,
                                 `F-4-4` == "Who developed the algorithm."~`F-4-2-4`,
                                 `F-4-5` == "Who developed the algorithm."~`F-4-2-5`,
                                 `F-4-6` == "Who developed the algorithm."~`F-4-2-6`,
                                 `F-4-7` == "Who developed the algorithm."~`F-4-2-7`,
                                 `F-4-8` == "Who developed the algorithm."~`F-4-2-8`)) %>%
  select(ResponseId, c4c1, c4c2, c41c, c42c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c4c1:c4c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c4c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c4c1", location11, location12)),
         moe= (ifelse(choiceNum == "c4c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c4c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c4c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c4c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c4c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c4c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c4c1", c41c, c42c)),
         defendant = 4,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendant5b <- conjoint3 %>%
  select(ResponseId, c5c1, c5c2, c51c, c52c, starts_with("F-5")) %>%
  mutate(nfactors11 = case_when(`F-5-1` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-1`,
                                `F-5-2` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-2`,
                                `F-5-3` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-3`,
                                `F-5-4` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-4`,
                                `F-5-5` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-5`,
                                `F-5-6` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-6`,
                                `F-5-7` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-7`,
                                `F-5-8` == "Number of factors the algorithm uses to make a recommendation."~`F-5-1-8`),
         location11 = case_when(`F-5-1` == "Location from which data to create the algorithm was collected."~`F-5-1-1`,
                                `F-5-2` == "Location from which data to create the algorithm was collected."~`F-5-1-2`,
                                `F-5-3` == "Location from which data to create the algorithm was collected."~`F-5-1-3`,
                                `F-5-4` == "Location from which data to create the algorithm was collected."~`F-5-1-4`,
                                `F-5-5` == "Location from which data to create the algorithm was collected."~`F-5-1-5`,
                                `F-5-6` == "Location from which data to create the algorithm was collected."~`F-5-1-6`,
                                `F-5-7` == "Location from which data to create the algorithm was collected."~`F-5-1-7`,
                                `F-5-8` == "Location from which data to create the algorithm was collected."~`F-5-1-8`),
         moe11 = case_when(`F-5-1` == "Estimated margin of error of probability estimates."~`F-5-1-1`,
                           `F-5-2` == "Estimated margin of error of probability estimates."~`F-5-1-2`,
                           `F-5-3` == "Estimated margin of error of probability estimates."~`F-5-1-3`,
                           `F-5-4` == "Estimated margin of error of probability estimates."~`F-5-1-4`,
                           `F-5-5` == "Estimated margin of error of probability estimates."~`F-5-1-5`,
                           `F-5-6` == "Estimated margin of error of probability estimates."~`F-5-1-6`,
                           `F-5-7` == "Estimated margin of error of probability estimates."~`F-5-1-7`,
                           `F-5-8` == "Estimated margin of error of probability estimates."~`F-5-1-8`),
         weights11 = case_when(`F-5-1` == "Amount of weight given to different factors."~`F-5-1-1`,
                               `F-5-2` == "Amount of weight given to different factors."~`F-5-1-2`,
                               `F-5-3` == "Amount of weight given to different factors."~`F-5-1-3`,
                               `F-5-4` == "Amount of weight given to different factors."~`F-5-1-4`,
                               `F-5-5` == "Amount of weight given to different factors."~`F-5-1-5`,
                               `F-5-6` == "Amount of weight given to different factors."~`F-5-1-6`,
                               `F-5-7` == "Amount of weight given to different factors."~`F-5-1-7`,
                               `F-5-8` == "Amount of weight given to different factors."~`F-5-1-8`),
         accuracy11 = case_when(`F-5-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-1`,
                                `F-5-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-2`,
                                `F-5-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-3`,
                                `F-5-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-4`,
                                `F-5-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-5`,
                                `F-5-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-6`,
                                `F-5-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-7`,
                                `F-5-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-1-8`),
         human11 = case_when(`F-5-1` == "Human involvement in final estimate (if any)."~`F-5-1-1`,
                             `F-5-2` == "Human involvement in final estimate (if any)."~`F-5-1-2`,
                             `F-5-3` == "Human involvement in final estimate (if any)."~`F-5-1-3`,
                             `F-5-4` == "Human involvement in final estimate (if any)."~`F-5-1-4`,
                             `F-5-5` == "Human involvement in final estimate (if any)."~`F-5-1-5`,
                             `F-5-6` == "Human involvement in final estimate (if any)."~`F-5-1-6`,
                             `F-5-7` == "Human involvement in final estimate (if any)."~`F-5-1-7`,
                             `F-5-8` == "Human involvement in final estimate (if any)."~`F-5-1-8`),
         datasize11 = case_when(`F-5-1` == "Number of cases used to create the algorithm."~`F-5-1-1`,
                                `F-5-2` == "Number of cases used to create the algorithm."~`F-5-1-2`,
                                `F-5-3` == "Number of cases used to create the algorithm."~`F-5-1-3`,
                                `F-5-4` == "Number of cases used to create the algorithm."~`F-5-1-4`,
                                `F-5-5` == "Number of cases used to create the algorithm."~`F-5-1-5`,
                                `F-5-6` == "Number of cases used to create the algorithm."~`F-5-1-6`,
                                `F-5-7` == "Number of cases used to create the algorithm."~`F-5-1-7`,
                                `F-5-8` == "Number of cases used to create the algorithm."~`F-5-1-8`),
         developer11 = case_when(`F-5-1` == "Who developed the algorithm."~`F-5-1-1`,
                                 `F-5-2` == "Who developed the algorithm."~`F-5-1-2`,
                                 `F-5-3` == "Who developed the algorithm."~`F-5-1-3`,
                                 `F-5-4` == "Who developed the algorithm."~`F-5-1-4`,
                                 `F-5-5` == "Who developed the algorithm."~`F-5-1-5`,
                                 `F-5-6` == "Who developed the algorithm."~`F-5-1-6`,
                                 `F-5-7` == "Who developed the algorithm."~`F-5-1-7`,
                                 `F-5-8` == "Who developed the algorithm."~`F-5-1-8`),
         nfactors12 = case_when(`F-5-1` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-1`,
                                `F-5-2` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-2`,
                                `F-5-3` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-3`,
                                `F-5-4` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-4`,
                                `F-5-5` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-5`,
                                `F-5-6` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-6`,
                                `F-5-7` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-7`,
                                `F-5-8` == "Number of factors the algorithm uses to make a recommendation."~`F-5-2-8`),
         location12 = case_when(`F-5-1` == "Location from which data to create the algorithm was collected."~`F-5-2-1`,
                                `F-5-2` == "Location from which data to create the algorithm was collected."~`F-5-2-2`,
                                `F-5-3` == "Location from which data to create the algorithm was collected."~`F-5-2-3`,
                                `F-5-4` == "Location from which data to create the algorithm was collected."~`F-5-2-4`,
                                `F-5-5` == "Location from which data to create the algorithm was collected."~`F-5-2-5`,
                                `F-5-6` == "Location from which data to create the algorithm was collected."~`F-5-2-6`,
                                `F-5-7` == "Location from which data to create the algorithm was collected."~`F-5-2-7`,
                                `F-5-8` == "Location from which data to create the algorithm was collected."~`F-5-2-8`),
         moe12 = case_when(`F-5-1` == "Estimated margin of error of probability estimates."~`F-5-2-1`,
                           `F-5-2` == "Estimated margin of error of probability estimates."~`F-5-2-2`,
                           `F-5-3` == "Estimated margin of error of probability estimates."~`F-5-2-3`,
                           `F-5-4` == "Estimated margin of error of probability estimates."~`F-5-2-4`,
                           `F-5-5` == "Estimated margin of error of probability estimates."~`F-5-2-5`,
                           `F-5-6` == "Estimated margin of error of probability estimates."~`F-5-2-6`,
                           `F-5-7` == "Estimated margin of error of probability estimates."~`F-5-2-7`,
                           `F-5-8` == "Estimated margin of error of probability estimates."~`F-5-2-8`),
         weights12 = case_when(`F-5-1` == "Amount of weight given to different factors."~`F-5-2-1`,
                               `F-5-2` == "Amount of weight given to different factors."~`F-5-2-2`,
                               `F-5-3` == "Amount of weight given to different factors."~`F-5-2-3`,
                               `F-5-4` == "Amount of weight given to different factors."~`F-5-2-4`,
                               `F-5-5` == "Amount of weight given to different factors."~`F-5-2-5`,
                               `F-5-6` == "Amount of weight given to different factors."~`F-5-2-6`,
                               `F-5-7` == "Amount of weight given to different factors."~`F-5-2-7`,
                               `F-5-8` == "Amount of weight given to different factors."~`F-5-2-8`),
         accuracy12 = case_when(`F-5-1` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-1`,
                                `F-5-2` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-2`,
                                `F-5-3` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-3`,
                                `F-5-4` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-4`,
                                `F-5-5` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-5`,
                                `F-5-6` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-6`,
                                `F-5-7` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-7`,
                                `F-5-8` == "Estimated accuracy of the algorithm based on the cases used to create it."~`F-5-2-8`),
         human12 = case_when(`F-5-1` == "Human involvement in final estimate (if any)."~`F-5-2-1`,
                             `F-5-2` == "Human involvement in final estimate (if any)."~`F-5-2-2`,
                             `F-5-3` == "Human involvement in final estimate (if any)."~`F-5-2-3`,
                             `F-5-4` == "Human involvement in final estimate (if any)."~`F-5-2-4`,
                             `F-5-5` == "Human involvement in final estimate (if any)."~`F-5-2-5`,
                             `F-5-6` == "Human involvement in final estimate (if any)."~`F-5-2-6`,
                             `F-5-7` == "Human involvement in final estimate (if any)."~`F-5-2-7`,
                             `F-5-8` == "Human involvement in final estimate (if any)."~`F-5-2-8`),
         datasize12 = case_when(`F-5-1` == "Number of cases used to create the algorithm."~`F-5-2-1`,
                                `F-5-2` == "Number of cases used to create the algorithm."~`F-5-2-2`,
                                `F-5-3` == "Number of cases used to create the algorithm."~`F-5-2-3`,
                                `F-5-4` == "Number of cases used to create the algorithm."~`F-5-2-4`,
                                `F-5-5` == "Number of cases used to create the algorithm."~`F-5-2-5`,
                                `F-5-6` == "Number of cases used to create the algorithm."~`F-5-2-6`,
                                `F-5-7` == "Number of cases used to create the algorithm."~`F-5-2-7`,
                                `F-5-8` == "Number of cases used to create the algorithm."~`F-5-2-8`),
         developer12 = case_when(`F-5-1` == "Who developed the algorithm."~`F-5-2-1`,
                                 `F-5-2` == "Who developed the algorithm."~`F-5-2-2`,
                                 `F-5-3` == "Who developed the algorithm."~`F-5-2-3`,
                                 `F-5-4` == "Who developed the algorithm."~`F-5-2-4`,
                                 `F-5-5` == "Who developed the algorithm."~`F-5-2-5`,
                                 `F-5-6` == "Who developed the algorithm."~`F-5-2-6`,
                                 `F-5-7` == "Who developed the algorithm."~`F-5-2-7`,
                                 `F-5-8` == "Who developed the algorithm."~`F-5-2-8`)) %>%
  select(ResponseId, c5c1, c5c2, c51c, c52c, nfactors11:developer12) %>%
  gather(choiceNum, chosen, c5c1:c5c2) %>%
  mutate(nfactors = (ifelse(choiceNum == "c5c1", nfactors11, nfactors12)),
         location = (ifelse(choiceNum == "c5c1", location11, location12)),
         moe= (ifelse(choiceNum == "c5c1", moe11, moe12)),
         weights = (ifelse(choiceNum == "c5c1", weights11, weights12)),
         accuracy = (ifelse(choiceNum == "c5c1", accuracy11, accuracy12)),
         human = (ifelse(choiceNum == "c5c1", human11, human12)),
         datasize = (ifelse(choiceNum == "c5c1", datasize11, datasize12)),
         developer = (ifelse(choiceNum == "c5c1", developer11, developer12)),
         acceptable = (ifelse(choiceNum == "c5c1", c51c, c52c)),
         defendant = 5,
         sample = "Lucid") %>%
  select(ResponseId, choiceNum, chosen, nfactors, location, moe, 
         weights, accuracy, human, datasize, developer, defendant,
         sample, acceptable)

defendants <- rbind(defendant1, defendant2, defendant3, defendant4, defendant5,
                    defendant1a, defendant2a, defendant3a, defendant4a, defendant5a,
                    defendant1b, defendant2b, defendant3b, defendant4b, defendant5b)

# Convert characteristics into variable for analysis of user preferences
defendants <- defendants %>%
  mutate(nfactors = factor(nfactors, levels = c("5 Factors","58 Factors","137 Factors")),
         location = factor(location, levels = c("Harris County, TX","Texas",
                                                "The state in which you currently reside",
                                                "All 50 states")),
         moe = factor(moe, levels = c("The expected error of the model's forecasts are not provided",
                                      "The model's forecasts have an expected error of plus or minus 5%",
                                      "The model's forecasts have an expected error of plus or minus 8%")),
         weights = factor(weights, levels = c("Weight given to factors is proprietary",
                                              "10% weight given to age, 30% to criminal history, 10% to peer group, and the rest to other factors",
                                              "20% weight given to age, 50% to criminal history, 10% to peer group, and the rest to other factors",
                                              "30% weight given to age, 30% to criminal history, 20% to peer group, and the rest to other factors")),
         accuracy = factor(accuracy, levels = c("81% of those forecast TO COMMIT a crime DID COMMIT a crime",
                                                "77% of those forecast TO COMMIT a crime DID COMMIT a crime",
                                                "69% of those forecast TO COMMIT a crime DID COMMIT a crime",
                                                "19% of those forecast TO COMMIT a crime DID NOT COMMIT a crime",
                                                "23% of those forecast TO COMMIT a crime DID NOT COMMIT a crime",
                                                "31% of those forecast TO COMMIT a crime DID NOT COMMIT a crime",
                                                "19% of those forecast TO NOT COMMIT a crime DID COMMIT a crime",
                                                "23% of those forecast TO NOT COMMIT a crime DID COMMIT a crime",
                                                "31% of those forecast TO NOT COMMIT a crime DID COMMIT a crime")),
         human = factor(human, levels = c("There is no human recommendation taken into account for the final score.",
                                          "A trained assessment officer reviews the case and provides a recommendation that makes up 25% of the final score.",
                                          "A trained assessment officer reviews the case and provides a recommendation that makes up 50% of the final score.")),
         datasize = factor(datasize, levels = c("10,000 cases", "50,000 cases",
                                                "100,000 cases", "500,000 cases",
                                                "1,000,000 cases")),
         developer = factor(developer, levels = c("Developed by a private firm",
                                                  "Developed by the U.S. Department of Justice",
                                                  "Developed by scholars at Harvard University")))

##############################
# Models for choices
##############################

# Logit conversion function for probabilities
logit2prob <- function(coefs){
  probs <- c()
  logit0 <- coefs[1]
  prob0 <- exp(logit0) / (1 + exp(logit0))
  probs <- c(probs, prob0)
  for(i in 2:length(coefs)){
    logit1 <- coefs[1] + coefs[i]
    prob1 <- exp(logit1) / (1 + exp(logit1))
    dprob1 <- prob1 - prob0
    probs <- c(probs, dprob1)
  }
  fprobs <- data.frame(probs)
  rownames(fprobs) <- rownames(data.frame(coefs))
  return(fprobs)
}

# Models for full data
# Figure 5b in main text and Table A11 in SI
model1 <- glm(chosen ~ nfactors + location + moe + weights + accuracy +
                human + datasize + developer, data = defendants,
              family = binomial(link = "logit"))
model1clust <- cluster.bs.glm(model1, defendants, ~ ResponseId, report = T)

coefprobs <- logit2prob(model1$coefficients)
problo <- logit2prob(model1clust$ci[,1])
probhi <- logit2prob(model1clust$ci[,2])

results <- data.frame(cbind(coefprobs, problo, probhi))
names(results) <- c("estimate", "cilo", "cihi")
results$condition <- rownames(results)
results$basecat <- substring(results$condition, 1, 3)
results$condition[results$condition == "nfactors58 Factors"] <- "58 Factors"
results$condition[results$condition == "nfactors137 Factors"] <- "137 Factors"
results$condition[results$condition == "locationTexas"] <- "Texas"
results$condition[results$condition == "locationThe state in which you currently reside"] <- "R's State"
results$condition[results$condition == "locationAll 50 states"] <- "All 50 States"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 5%"] <- "Plus or Minus 5"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 8%"] <- "Plus or Minus 8"
results$condition[results$condition == "weights10% weight given to age, 30% to criminal history, 10% to peer group, and the rest to other factors"] <- "30% to top, 50% revealed"
results$condition[results$condition == "weights20% weight given to age, 50% to criminal history, 10% to peer group, and the rest to other factors"] <- "50% to top, 80% revealed"
results$condition[results$condition == "weights30% weight given to age, 30% to criminal history, 20% to peer group, and the rest to other factors"] <- "30% to top, 80% revealed"
results$condition[results$condition == "accuracy77% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "77% True Positive"
results$condition[results$condition == "accuracy69% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "69% True Positive"
results$condition[results$condition == "accuracy19% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "19% False Positive"
results$condition[results$condition == "accuracy23% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "23% False Positive"
results$condition[results$condition == "accuracy31% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "31% False Positive"
results$condition[results$condition == "accuracy19% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "19% False Negative"
results$condition[results$condition == "accuracy23% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "23% False Negative"
results$condition[results$condition == "accuracy31% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "31% False Negative"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 25% of the final score."] <- "25% human"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 50% of the final score."] <- "50% human"
results$condition[results$condition == "datasize50,000 cases"] <- "50,000 cases"
results$condition[results$condition == "datasize100,000 cases"] <- "100,000 cases"
results$condition[results$condition == "datasize500,000 cases"] <- "500,000 cases"
results$condition[results$condition == "datasize1,000,000 cases"] <- "1,000,000 cases"
results$condition[results$condition == "developerDeveloped by the U.S. Department of Justice"] <- "U.S. Department of Justice"
results$condition[results$condition == "developerDeveloped by scholars at Harvard University"] <- "Harvard University"
results$basecat[results$basecat == "acc"] <- "e"
results$basecat[results$basecat == "dat"] <- "a"
results$basecat[results$basecat == "dev"] <- "h"
results$basecat[results$basecat == "hum"] <- "g"
results$basecat[results$basecat == "loc"] <- "b"
results$basecat[results$basecat == "moe"] <- "f"
results$basecat[results$basecat == "nfa"] <- "c"
results$basecat[results$basecat == "wei"] <- "d"
results$basecat[results$basecat == "(In"] <- "I"


addbasecats <- data.frame(rbind(c(0,0,0,"Weights Proprietary", "d"),
                                c(0,0,0,"5 Factors", "c"),
                                c(0,0,0,"Forecast Error Not Provided", "f"),
                                c(0,0,0,"Harris County, TX", "b"),
                                c(0,0,0, "No Human", "g"),
                                c(0,0,0,"Private Firm", "h"),
                                c(0,0,0,"10,000 cases", "a"),
                                c(0,0,0,"81% True Positive", "e")))
names(addbasecats) <- c("estimate","cilo","cihi","condition","basecat")

results <- rbind(results, addbasecats)

results <- results %>%
  mutate(condition = factor(condition, levels = c("10,000 cases", "50,000 cases",
                                                  "100,000 cases", "500,000 cases",
                                                  "1,000,000 cases","Harris County, TX","Texas",
                                                  "R's State",
                                                  "All 50 States",
                                                  "5 Factors","58 Factors","137 Factors",
                                                  "Weights Proprietary",
                                                  "30% to top, 50% revealed",
                                                  "50% to top, 80% revealed",
                                                  "30% to top, 80% revealed",
                                                  "81% True Positive",
                                                  "77% True Positive",
                                                  "69% True Positive",
                                                  "19% False Positive",
                                                  "23% False Positive",
                                                  "31% False Positive",
                                                  "19% False Negative",
                                                  "23% False Negative",
                                                  "31% False Negative",
                                                  "Forecast Error Not Provided",
                                                  "Plus or Minus 5",
                                                  "Plus or Minus 8",
                                                  "No Human",
                                                  "25% human",
                                                  "50% human",
                                                  "Private Firm",
                                                  "U.S. Department of Justice",
                                                  "Harvard University")))

results$estimate <- as.numeric(results$estimate)
results$cilo <- as.numeric(results$cilo)
results$cihi <- as.numeric(results$cihi)

p1 = ggplot(results[results$basecat != "I",]) + 
  geom_point(aes(condition, estimate)) +
  geom_errorbar(aes(x = condition, ymin=cilo, ymax=cihi), width=.1) +
  facet_grid(basecat ~ ., space="free_y", scales="free_y", switch="y") + 
  theme_classic() +
  theme(strip.placement = "outside",
        strip.background = element_rect(fill=NA, colour="grey50"),
        panel.spacing.x=unit(0,"cm")) + coord_flip() + geom_hline(yintercept = 0) +
  labs(x = "Condition", y = "Effect on Pr(Algorithm Preferred)")
p1
ggsave(here("conjointGraph.png"),
       plot = p1, device = "png", width = 4.5, height = 9.5)

# Get results for only the MTurk sample for SI
model2 <- glm(chosen ~ nfactors + location + moe + weights + accuracy +
                human + datasize + developer, data = defendants[defendants$sample == "MTurk",],
              family = binomial(link = "logit"))
model2clust <- cluster.bs.glm(model2, defendants[defendants$sample == "MTurk",], ~ ResponseId, report = T)
# Plot MTurk results for Figure A21 left in SI
coefprobs <- logit2prob(model2$coefficients)
problo <- logit2prob(model2clust$ci[,1])
probhi <- logit2prob(model2clust$ci[,2])

results <- data.frame(cbind(coefprobs, problo, probhi))
names(results) <- c("estimate", "cilo", "cihi")
results$condition <- rownames(results)
results$basecat <- substring(results$condition, 1, 3)
results$condition[results$condition == "nfactors58 Factors"] <- "58 Factors"
results$condition[results$condition == "nfactors137 Factors"] <- "137 Factors"
results$condition[results$condition == "locationTexas"] <- "Texas"
results$condition[results$condition == "locationThe state in which you currently reside"] <- "R's State"
results$condition[results$condition == "locationAll 50 states"] <- "All 50 States"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 5%"] <- "Plus or Minus 5"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 8%"] <- "Plus or Minus 8"
results$condition[results$condition == "weights10% weight given to age, 30% to criminal history, 10% to peer group, and the rest to other factors"] <- "30% to top, 50% revealed"
results$condition[results$condition == "weights20% weight given to age, 50% to criminal history, 10% to peer group, and the rest to other factors"] <- "50% to top, 80% revealed"
results$condition[results$condition == "weights30% weight given to age, 30% to criminal history, 20% to peer group, and the rest to other factors"] <- "30% to top, 80% revealed"
results$condition[results$condition == "accuracy77% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "77% True Positive"
results$condition[results$condition == "accuracy69% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "69% True Positive"
results$condition[results$condition == "accuracy19% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "19% False Positive"
results$condition[results$condition == "accuracy23% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "23% False Positive"
results$condition[results$condition == "accuracy31% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "31% False Positive"
results$condition[results$condition == "accuracy19% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "19% False Negative"
results$condition[results$condition == "accuracy23% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "23% False Negative"
results$condition[results$condition == "accuracy31% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "31% False Negative"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 25% of the final score."] <- "25% human"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 50% of the final score."] <- "50% human"
results$condition[results$condition == "datasize50,000 cases"] <- "50,000 cases"
results$condition[results$condition == "datasize100,000 cases"] <- "100,000 cases"
results$condition[results$condition == "datasize500,000 cases"] <- "500,000 cases"
results$condition[results$condition == "datasize1,000,000 cases"] <- "1,000,000 cases"
results$condition[results$condition == "developerDeveloped by the U.S. Department of Justice"] <- "U.S. Department of Justice"
results$condition[results$condition == "developerDeveloped by scholars at Harvard University"] <- "Harvard University"
results$basecat[results$basecat == "acc"] <- "e"
results$basecat[results$basecat == "dat"] <- "a"
results$basecat[results$basecat == "dev"] <- "h"
results$basecat[results$basecat == "hum"] <- "g"
results$basecat[results$basecat == "loc"] <- "b"
results$basecat[results$basecat == "moe"] <- "f"
results$basecat[results$basecat == "nfa"] <- "c"
results$basecat[results$basecat == "wei"] <- "d"
results$basecat[results$basecat == "(In"] <- "I"


addbasecats <- data.frame(rbind(c(0,0,0,"Weights Proprietary", "d"),
                                c(0,0,0,"5 Factors", "c"),
                                c(0,0,0,"Forecast Error Not Provided", "f"),
                                c(0,0,0,"Harris County, TX", "b"),
                                c(0,0,0, "No Human", "g"),
                                c(0,0,0,"Private Firm", "h"),
                                c(0,0,0,"10,000 cases", "a"),
                                c(0,0,0,"81% True Positive", "e")))
names(addbasecats) <- c("estimate","cilo","cihi","condition","basecat")

results <- rbind(results, addbasecats)

results <- results %>%
  mutate(condition = factor(condition, levels = c("10,000 cases", "50,000 cases",
                                                  "100,000 cases", "500,000 cases",
                                                  "1,000,000 cases","Harris County, TX","Texas",
                                                  "R's State",
                                                  "All 50 States",
                                                  "5 Factors","58 Factors","137 Factors",
                                                  "Weights Proprietary",
                                                  "30% to top, 50% revealed",
                                                  "50% to top, 80% revealed",
                                                  "30% to top, 80% revealed",
                                                  "81% True Positive",
                                                  "77% True Positive",
                                                  "69% True Positive",
                                                  "19% False Positive",
                                                  "23% False Positive",
                                                  "31% False Positive",
                                                  "19% False Negative",
                                                  "23% False Negative",
                                                  "31% False Negative",
                                                  "Forecast Error Not Provided",
                                                  "Plus or Minus 5",
                                                  "Plus or Minus 8",
                                                  "No Human",
                                                  "25% human",
                                                  "50% human",
                                                  "Private Firm",
                                                  "U.S. Department of Justice",
                                                  "Harvard University")))

results$estimate <- as.numeric(results$estimate)
results$cilo <- as.numeric(results$cilo)
results$cihi <- as.numeric(results$cihi)

p2 = ggplot(results[results$basecat != "I",]) + 
  geom_point(aes(condition, estimate)) +
  geom_errorbar(aes(x = condition, ymin=cilo, ymax=cihi), width=.1) +
  facet_grid(basecat ~ ., space="free_y", scales="free_y", switch="y") + 
  theme_classic() +
  theme(strip.placement = "outside",
        strip.background = element_rect(fill=NA, colour="grey50"),
        panel.spacing.x=unit(0,"cm")) + coord_flip() + geom_hline(yintercept = 0) +
  labs(x = "Condition", y = "Effect on Pr(Algorithm Preferred)")
p2
ggsave(here("conjointGraph(MTurk).png"),
       plot = p2, device = "png", width = 4.5, height = 9.5)


# Get results for only the Lucid sample for SI
model3 <- glm(chosen ~ nfactors + location + moe + weights + accuracy +
                human + datasize + developer, data = defendants[defendants$sample == "Lucid",],
              family = binomial(link = "logit"))
model3clust <- cluster.bs.glm(model3, defendants[defendants$sample == "Lucid",], ~ ResponseId, report = T)
# Generate Figure A21 right for SI
coefprobs <- logit2prob(model3$coefficients)
problo <- logit2prob(model3clust$ci[,1])
probhi <- logit2prob(model3clust$ci[,2])

results <- data.frame(cbind(coefprobs, problo, probhi))
names(results) <- c("estimate", "cilo", "cihi")
results$condition <- rownames(results)
results$basecat <- substring(results$condition, 1, 3)
results$condition[results$condition == "nfactors58 Factors"] <- "58 Factors"
results$condition[results$condition == "nfactors137 Factors"] <- "137 Factors"
results$condition[results$condition == "locationTexas"] <- "Texas"
results$condition[results$condition == "locationThe state in which you currently reside"] <- "R's State"
results$condition[results$condition == "locationAll 50 states"] <- "All 50 States"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 5%"] <- "Plus or Minus 5"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 8%"] <- "Plus or Minus 8"
results$condition[results$condition == "weights10% weight given to age, 30% to criminal history, 10% to peer group, and the rest to other factors"] <- "30% to top, 50% revealed"
results$condition[results$condition == "weights20% weight given to age, 50% to criminal history, 10% to peer group, and the rest to other factors"] <- "50% to top, 80% revealed"
results$condition[results$condition == "weights30% weight given to age, 30% to criminal history, 20% to peer group, and the rest to other factors"] <- "30% to top, 80% revealed"
results$condition[results$condition == "accuracy77% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "77% True Positive"
results$condition[results$condition == "accuracy69% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "69% True Positive"
results$condition[results$condition == "accuracy19% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "19% False Positive"
results$condition[results$condition == "accuracy23% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "23% False Positive"
results$condition[results$condition == "accuracy31% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "31% False Positive"
results$condition[results$condition == "accuracy19% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "19% False Negative"
results$condition[results$condition == "accuracy23% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "23% False Negative"
results$condition[results$condition == "accuracy31% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "31% False Negative"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 25% of the final score."] <- "25% human"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 50% of the final score."] <- "50% human"
results$condition[results$condition == "datasize50,000 cases"] <- "50,000 cases"
results$condition[results$condition == "datasize100,000 cases"] <- "100,000 cases"
results$condition[results$condition == "datasize500,000 cases"] <- "500,000 cases"
results$condition[results$condition == "datasize1,000,000 cases"] <- "1,000,000 cases"
results$condition[results$condition == "developerDeveloped by the U.S. Department of Justice"] <- "U.S. Department of Justice"
results$condition[results$condition == "developerDeveloped by scholars at Harvard University"] <- "Harvard University"
results$basecat[results$basecat == "acc"] <- "e"
results$basecat[results$basecat == "dat"] <- "a"
results$basecat[results$basecat == "dev"] <- "h"
results$basecat[results$basecat == "hum"] <- "g"
results$basecat[results$basecat == "loc"] <- "b"
results$basecat[results$basecat == "moe"] <- "f"
results$basecat[results$basecat == "nfa"] <- "c"
results$basecat[results$basecat == "wei"] <- "d"
results$basecat[results$basecat == "(In"] <- "I"


addbasecats <- data.frame(rbind(c(0,0,0,"Weights Proprietary", "d"),
                                c(0,0,0,"5 Factors", "c"),
                                c(0,0,0,"Forecast Error Not Provided", "f"),
                                c(0,0,0,"Harris County, TX", "b"),
                                c(0,0,0, "No Human", "g"),
                                c(0,0,0,"Private Firm", "h"),
                                c(0,0,0,"10,000 cases", "a"),
                                c(0,0,0,"81% True Positive", "e")))
names(addbasecats) <- c("estimate","cilo","cihi","condition","basecat")

results <- rbind(results, addbasecats)

results <- results %>%
  mutate(condition = factor(condition, levels = c("10,000 cases", "50,000 cases",
                                                  "100,000 cases", "500,000 cases",
                                                  "1,000,000 cases","Harris County, TX","Texas",
                                                  "R's State",
                                                  "All 50 States",
                                                  "5 Factors","58 Factors","137 Factors",
                                                  "Weights Proprietary",
                                                  "30% to top, 50% revealed",
                                                  "50% to top, 80% revealed",
                                                  "30% to top, 80% revealed",
                                                  "81% True Positive",
                                                  "77% True Positive",
                                                  "69% True Positive",
                                                  "19% False Positive",
                                                  "23% False Positive",
                                                  "31% False Positive",
                                                  "19% False Negative",
                                                  "23% False Negative",
                                                  "31% False Negative",
                                                  "Forecast Error Not Provided",
                                                  "Plus or Minus 5",
                                                  "Plus or Minus 8",
                                                  "No Human",
                                                  "25% human",
                                                  "50% human",
                                                  "Private Firm",
                                                  "U.S. Department of Justice",
                                                  "Harvard University")))

results$estimate <- as.numeric(results$estimate)
results$cilo <- as.numeric(results$cilo)
results$cihi <- as.numeric(results$cihi)

p3 = ggplot(results[results$basecat != "I",]) + 
  geom_point(aes(condition, estimate)) +
  geom_errorbar(aes(x = condition, ymin=cilo, ymax=cihi), width=.1) +
  facet_grid(basecat ~ ., space="free_y", scales="free_y", switch="y") + 
  theme_classic() +
  theme(strip.placement = "outside",
        strip.background = element_rect(fill=NA, colour="grey50"),
        panel.spacing.x=unit(0,"cm")) + coord_flip() + geom_hline(yintercept = 0) +
  labs(x = "Condition", y = "Effect on Pr(Algorithm Preferred)")
p3
ggsave(here("conjointGraph(Lucid).png"),
       plot = p3, device = "png", width = 4.5, height = 9.5)

# Create a table of the conjoint results
# Table A11 in SI
sink(here("REtableConjoint.tex"))
stargazer(list(model1, model2, model3),
          p = list(model1clust$p.values, model2clust$p.values, model3clust$p.values),
          report = "vcp",
          style="ajps", 
          title="Conjoint Experiment Results - Criminal Justice Algorithms", 
          dep.var.labels.include = FALSE, 
          column.labels = c("Full Data", "MTurk", "Lucid"),
          covariate.labels=c( "58 Factors", "137 Factors", 
                              "Texas",
                              "R's State", "All 50 States",
                              "Plus or Minus 5",
                              "Plus or Minus 8",
                              "30\\% to top, 50\\% revealed",
                              "50\\% to top, 80\\% revealed",
                              "30\\% to top, 80\\% revealed",
                              "77\\% True Positive",
                              "69\\% True Positive",
                              "19\\% False Positive",
                              "23\\% False Positive",
                              "31\\% False Positive",
                              "19\\% False Negative",
                              "23\\% False Negative",
                              "31\\% False Negative",
                              "25\\% Human",
                              "50\\% Human",
                              "50,000 cases",
                              "100,000 cases",
                              "500,000 cases",
                              "1,000,000 cases",
                              "U.S. Department of Justice",
                              "Harvard University"),
          header = F)
sink()



######################################
# Models for the choice ratings
######################################

# Models for full data
# Figure A23
model1 <- glm(acceptable ~ nfactors + location + moe + weights + accuracy +
                human + datasize + developer, data = defendants,
              family = binomial(link = "logit"))
model1clust <- cluster.bs.glm(model1, defendants, ~ ResponseId, report = T)

coefprobs <- logit2prob(model1$coefficients)
problo <- logit2prob(model1clust$ci[,1])
probhi <- logit2prob(model1clust$ci[,2])

results <- data.frame(cbind(coefprobs, problo, probhi))
names(results) <- c("estimate", "cilo", "cihi")
results$condition <- rownames(results)
results$basecat <- substring(results$condition, 1, 3)
results$condition[results$condition == "nfactors58 Factors"] <- "58 Factors"
results$condition[results$condition == "nfactors137 Factors"] <- "137 Factors"
results$condition[results$condition == "locationTexas"] <- "Texas"
results$condition[results$condition == "locationThe state in which you currently reside"] <- "R's State"
results$condition[results$condition == "locationAll 50 states"] <- "All 50 States"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 5%"] <- "Plus or Minus 5"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 8%"] <- "Plus or Minus 8"
results$condition[results$condition == "weights10% weight given to age, 30% to criminal history, 10% to peer group, and the rest to other factors"] <- "30% to top, 50% revealed"
results$condition[results$condition == "weights20% weight given to age, 50% to criminal history, 10% to peer group, and the rest to other factors"] <- "50% to top, 80% revealed"
results$condition[results$condition == "weights30% weight given to age, 30% to criminal history, 20% to peer group, and the rest to other factors"] <- "30% to top, 80% revealed"
results$condition[results$condition == "accuracy77% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "77% True Positive"
results$condition[results$condition == "accuracy69% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "69% True Positive"
results$condition[results$condition == "accuracy19% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "19% False Positive"
results$condition[results$condition == "accuracy23% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "23% False Positive"
results$condition[results$condition == "accuracy31% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "31% False Positive"
results$condition[results$condition == "accuracy19% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "19% False Negative"
results$condition[results$condition == "accuracy23% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "23% False Negative"
results$condition[results$condition == "accuracy31% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "31% False Negative"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 25% of the final score."] <- "25% human"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 50% of the final score."] <- "50% human"
results$condition[results$condition == "datasize50,000 cases"] <- "50,000 cases"
results$condition[results$condition == "datasize100,000 cases"] <- "100,000 cases"
results$condition[results$condition == "datasize500,000 cases"] <- "500,000 cases"
results$condition[results$condition == "datasize1,000,000 cases"] <- "1,000,000 cases"
results$condition[results$condition == "developerDeveloped by the U.S. Department of Justice"] <- "U.S. Department of Justice"
results$condition[results$condition == "developerDeveloped by scholars at Harvard University"] <- "Harvard University"
results$basecat[results$basecat == "acc"] <- "e"
results$basecat[results$basecat == "dat"] <- "a"
results$basecat[results$basecat == "dev"] <- "h"
results$basecat[results$basecat == "hum"] <- "g"
results$basecat[results$basecat == "loc"] <- "b"
results$basecat[results$basecat == "moe"] <- "f"
results$basecat[results$basecat == "nfa"] <- "c"
results$basecat[results$basecat == "wei"] <- "d"
results$basecat[results$basecat == "(In"] <- "I"


addbasecats <- data.frame(rbind(c(0,0,0,"Weights Proprietary", "d"),
                                c(0,0,0,"5 Factors", "c"),
                                c(0,0,0,"Forecast Error Not Provided", "f"),
                                c(0,0,0,"Harris County, TX", "b"),
                                c(0,0,0, "No Human", "g"),
                                c(0,0,0,"Private Firm", "h"),
                                c(0,0,0,"10,000 cases", "a"),
                                c(0,0,0,"81% True Positive", "e")))
names(addbasecats) <- c("estimate","cilo","cihi","condition","basecat")

results <- rbind(results, addbasecats)

results <- results %>%
  mutate(condition = factor(condition, levels = c("10,000 cases", "50,000 cases",
                                                  "100,000 cases", "500,000 cases",
                                                  "1,000,000 cases","Harris County, TX","Texas",
                                                  "R's State",
                                                  "All 50 States",
                                                  "5 Factors","58 Factors","137 Factors",
                                                  "Weights Proprietary",
                                                  "30% to top, 50% revealed",
                                                  "50% to top, 80% revealed",
                                                  "30% to top, 80% revealed",
                                                  "81% True Positive",
                                                  "77% True Positive",
                                                  "69% True Positive",
                                                  "19% False Positive",
                                                  "23% False Positive",
                                                  "31% False Positive",
                                                  "19% False Negative",
                                                  "23% False Negative",
                                                  "31% False Negative",
                                                  "Forecast Error Not Provided",
                                                  "Plus or Minus 5",
                                                  "Plus or Minus 8",
                                                  "No Human",
                                                  "25% human",
                                                  "50% human",
                                                  "Private Firm",
                                                  "U.S. Department of Justice",
                                                  "Harvard University")))

results$estimate <- as.numeric(results$estimate)
results$cilo <- as.numeric(results$cilo)
results$cihi <- as.numeric(results$cihi)

p1 = ggplot(results[results$basecat != "I",]) + 
  geom_point(aes(condition, estimate)) +
  geom_errorbar(aes(x = condition, ymin=cilo, ymax=cihi), width=.1) +
  facet_grid(basecat ~ ., space="free_y", scales="free_y", switch="y") + 
  theme_classic() +
  theme(strip.placement = "outside",
        strip.background = element_rect(fill=NA, colour="grey50"),
        panel.spacing.x=unit(0,"cm")) + coord_flip() + geom_hline(yintercept = 0) +
  labs(x = "Condition", y = "Effect on Pr(Algorithm Acceptance)")
p1
ggsave(here("conjointGraphRate.png"),
       plot = p1, device = "png", width = 4.5, height = 9.5)

# Create a table of the conjoint results
# Table A25
sink(here("REtableConjointRate.tex"))
stargazer(list(model1, model2, model3),
          p = list(model1clust$p.values, model2clust$p.values, model3clust$p.values),
          report = "vcp",
          style="ajps", 
          title="Conjoint Experiment Results - Criminal Justice Algorithms", 
          dep.var.labels.include = FALSE, 
          column.labels = c("Full Data", "MTurk", "Lucid"),
          covariate.labels=c( "58 Factors", "137 Factors", 
                              "Texas",
                              "R's State", "All 50 States",
                              "Plus or Minus 5",
                              "Plus or Minus 8",
                              "30\\% to top, 50\\% revealed",
                              "50\\% to top, 80\\% revealed",
                              "30\\% to top, 80\\% revealed",
                              "77\\% True Positive",
                              "69\\% True Positive",
                              "19\\% False Positive",
                              "23\\% False Positive",
                              "31\\% False Positive",
                              "19\\% False Negative",
                              "23\\% False Negative",
                              "31\\% False Negative",
                              "25\\% Human",
                              "50\\% Human",
                              "50,000 cases",
                              "100,000 cases",
                              "500,000 cases",
                              "1,000,000 cases",
                              "U.S. Department of Justice",
                              "Harvard University"),
          header = F)
sink()

# Create plots for each sample independently
# Figure A24 in SI, left and right
# Get plots for only the MTurk sample
model2 <- glm(acceptable ~ nfactors + location + moe + weights + accuracy +
                human + datasize + developer, data = defendants[defendants$sample == "MTurk",],
              family = binomial(link = "logit"))
model2clust <- cluster.bs.glm(model2, defendants[defendants$sample == "MTurk",], ~ ResponseId, report = T)

coefprobs <- logit2prob(model2$coefficients)
problo <- logit2prob(model2clust$ci[,1])
probhi <- logit2prob(model2clust$ci[,2])

results <- data.frame(cbind(coefprobs, problo, probhi))
names(results) <- c("estimate", "cilo", "cihi")
results$condition <- rownames(results)
results$basecat <- substring(results$condition, 1, 3)
results$condition[results$condition == "nfactors58 Factors"] <- "58 Factors"
results$condition[results$condition == "nfactors137 Factors"] <- "137 Factors"
results$condition[results$condition == "locationTexas"] <- "Texas"
results$condition[results$condition == "locationThe state in which you currently reside"] <- "R's State"
results$condition[results$condition == "locationAll 50 states"] <- "All 50 States"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 5%"] <- "Plus or Minus 5"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 8%"] <- "Plus or Minus 8"
results$condition[results$condition == "weights10% weight given to age, 30% to criminal history, 10% to peer group, and the rest to other factors"] <- "30% to top, 50% revealed"
results$condition[results$condition == "weights20% weight given to age, 50% to criminal history, 10% to peer group, and the rest to other factors"] <- "50% to top, 80% revealed"
results$condition[results$condition == "weights30% weight given to age, 30% to criminal history, 20% to peer group, and the rest to other factors"] <- "30% to top, 80% revealed"
results$condition[results$condition == "accuracy77% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "77% True Positive"
results$condition[results$condition == "accuracy69% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "69% True Positive"
results$condition[results$condition == "accuracy19% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "19% False Positive"
results$condition[results$condition == "accuracy23% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "23% False Positive"
results$condition[results$condition == "accuracy31% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "31% False Positive"
results$condition[results$condition == "accuracy19% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "19% False Negative"
results$condition[results$condition == "accuracy23% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "23% False Negative"
results$condition[results$condition == "accuracy31% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "31% False Negative"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 25% of the final score."] <- "25% human"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 50% of the final score."] <- "50% human"
results$condition[results$condition == "datasize50,000 cases"] <- "50,000 cases"
results$condition[results$condition == "datasize100,000 cases"] <- "100,000 cases"
results$condition[results$condition == "datasize500,000 cases"] <- "500,000 cases"
results$condition[results$condition == "datasize1,000,000 cases"] <- "1,000,000 cases"
results$condition[results$condition == "developerDeveloped by the U.S. Department of Justice"] <- "U.S. Department of Justice"
results$condition[results$condition == "developerDeveloped by scholars at Harvard University"] <- "Harvard University"
results$basecat[results$basecat == "acc"] <- "e"
results$basecat[results$basecat == "dat"] <- "a"
results$basecat[results$basecat == "dev"] <- "h"
results$basecat[results$basecat == "hum"] <- "g"
results$basecat[results$basecat == "loc"] <- "b"
results$basecat[results$basecat == "moe"] <- "f"
results$basecat[results$basecat == "nfa"] <- "c"
results$basecat[results$basecat == "wei"] <- "d"
results$basecat[results$basecat == "(In"] <- "I"


addbasecats <- data.frame(rbind(c(0,0,0,"Weights Proprietary", "d"),
                                c(0,0,0,"5 Factors", "c"),
                                c(0,0,0,"Forecast Error Not Provided", "f"),
                                c(0,0,0,"Harris County, TX", "b"),
                                c(0,0,0, "No Human", "g"),
                                c(0,0,0,"Private Firm", "h"),
                                c(0,0,0,"10,000 cases", "a"),
                                c(0,0,0,"81% True Positive", "e")))
names(addbasecats) <- c("estimate","cilo","cihi","condition","basecat")

results <- rbind(results, addbasecats)

results <- results %>%
  mutate(condition = factor(condition, levels = c("10,000 cases", "50,000 cases",
                                                  "100,000 cases", "500,000 cases",
                                                  "1,000,000 cases","Harris County, TX","Texas",
                                                  "R's State",
                                                  "All 50 States",
                                                  "5 Factors","58 Factors","137 Factors",
                                                  "Weights Proprietary",
                                                  "30% to top, 50% revealed",
                                                  "50% to top, 80% revealed",
                                                  "30% to top, 80% revealed",
                                                  "81% True Positive",
                                                  "77% True Positive",
                                                  "69% True Positive",
                                                  "19% False Positive",
                                                  "23% False Positive",
                                                  "31% False Positive",
                                                  "19% False Negative",
                                                  "23% False Negative",
                                                  "31% False Negative",
                                                  "Forecast Error Not Provided",
                                                  "Plus or Minus 5",
                                                  "Plus or Minus 8",
                                                  "No Human",
                                                  "25% human",
                                                  "50% human",
                                                  "Private Firm",
                                                  "U.S. Department of Justice",
                                                  "Harvard University")))

results$estimate <- as.numeric(results$estimate)
results$cilo <- as.numeric(results$cilo)
results$cihi <- as.numeric(results$cihi)

p2 = ggplot(results[results$basecat != "I",]) + 
  geom_point(aes(condition, estimate)) +
  geom_errorbar(aes(x = condition, ymin=cilo, ymax=cihi), width=.1) +
  facet_grid(basecat ~ ., space="free_y", scales="free_y", switch="y") + 
  theme_classic() +
  theme(strip.placement = "outside",
        strip.background = element_rect(fill=NA, colour="grey50"),
        panel.spacing.x=unit(0,"cm")) + coord_flip() + geom_hline(yintercept = 0) +
  labs(x = "Condition", y = "Effect on Pr(Algorithm Acceptance)")
p2
ggsave(here("conjointGraphRate(MTurk).png"),
       plot = p2, device = "png", width = 4.5, height = 9.5)

# Get plots for only the Lucid sample
model3 <- glm(acceptable ~ nfactors + location + moe + weights + accuracy +
                human + datasize + developer, data = defendants[defendants$sample == "Lucid",],
              family = binomial(link = "logit"))
model3clust <- cluster.bs.glm(model3, defendants[defendants$sample == "Lucid",], ~ ResponseId, report = T)

coefprobs <- logit2prob(model3$coefficients)
problo <- logit2prob(model3clust$ci[,1])
probhi <- logit2prob(model3clust$ci[,2])

results <- data.frame(cbind(coefprobs, problo, probhi))
names(results) <- c("estimate", "cilo", "cihi")
results$condition <- rownames(results)
results$basecat <- substring(results$condition, 1, 3)
results$condition[results$condition == "nfactors58 Factors"] <- "58 Factors"
results$condition[results$condition == "nfactors137 Factors"] <- "137 Factors"
results$condition[results$condition == "locationTexas"] <- "Texas"
results$condition[results$condition == "locationThe state in which you currently reside"] <- "R's State"
results$condition[results$condition == "locationAll 50 states"] <- "All 50 States"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 5%"] <- "Plus or Minus 5"
results$condition[results$condition == "moeThe model's forecasts have an expected error of plus or minus 8%"] <- "Plus or Minus 8"
results$condition[results$condition == "weights10% weight given to age, 30% to criminal history, 10% to peer group, and the rest to other factors"] <- "30% to top, 50% revealed"
results$condition[results$condition == "weights20% weight given to age, 50% to criminal history, 10% to peer group, and the rest to other factors"] <- "50% to top, 80% revealed"
results$condition[results$condition == "weights30% weight given to age, 30% to criminal history, 20% to peer group, and the rest to other factors"] <- "30% to top, 80% revealed"
results$condition[results$condition == "accuracy77% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "77% True Positive"
results$condition[results$condition == "accuracy69% of those forecast TO COMMIT a crime DID COMMIT a crime"] <- "69% True Positive"
results$condition[results$condition == "accuracy19% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "19% False Positive"
results$condition[results$condition == "accuracy23% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "23% False Positive"
results$condition[results$condition == "accuracy31% of those forecast TO COMMIT a crime DID NOT COMMIT a crime"] <- "31% False Positive"
results$condition[results$condition == "accuracy19% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "19% False Negative"
results$condition[results$condition == "accuracy23% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "23% False Negative"
results$condition[results$condition == "accuracy31% of those forecast TO NOT COMMIT a crime DID COMMIT a crime"] <- "31% False Negative"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 25% of the final score."] <- "25% human"
results$condition[results$condition == "humanA trained assessment officer reviews the case and provides a recommendation that makes up 50% of the final score."] <- "50% human"
results$condition[results$condition == "datasize50,000 cases"] <- "50,000 cases"
results$condition[results$condition == "datasize100,000 cases"] <- "100,000 cases"
results$condition[results$condition == "datasize500,000 cases"] <- "500,000 cases"
results$condition[results$condition == "datasize1,000,000 cases"] <- "1,000,000 cases"
results$condition[results$condition == "developerDeveloped by the U.S. Department of Justice"] <- "U.S. Department of Justice"
results$condition[results$condition == "developerDeveloped by scholars at Harvard University"] <- "Harvard University"
results$basecat[results$basecat == "acc"] <- "e"
results$basecat[results$basecat == "dat"] <- "a"
results$basecat[results$basecat == "dev"] <- "h"
results$basecat[results$basecat == "hum"] <- "g"
results$basecat[results$basecat == "loc"] <- "b"
results$basecat[results$basecat == "moe"] <- "f"
results$basecat[results$basecat == "nfa"] <- "c"
results$basecat[results$basecat == "wei"] <- "d"
results$basecat[results$basecat == "(In"] <- "I"


addbasecats <- data.frame(rbind(c(0,0,0,"Weights Proprietary", "d"),
                                c(0,0,0,"5 Factors", "c"),
                                c(0,0,0,"Forecast Error Not Provided", "f"),
                                c(0,0,0,"Harris County, TX", "b"),
                                c(0,0,0, "No Human", "g"),
                                c(0,0,0,"Private Firm", "h"),
                                c(0,0,0,"10,000 cases", "a"),
                                c(0,0,0,"81% True Positive", "e")))
names(addbasecats) <- c("estimate","cilo","cihi","condition","basecat")

results <- rbind(results, addbasecats)

results <- results %>%
  mutate(condition = factor(condition, levels = c("10,000 cases", "50,000 cases",
                                                  "100,000 cases", "500,000 cases",
                                                  "1,000,000 cases","Harris County, TX","Texas",
                                                  "R's State",
                                                  "All 50 States",
                                                  "5 Factors","58 Factors","137 Factors",
                                                  "Weights Proprietary",
                                                  "30% to top, 50% revealed",
                                                  "50% to top, 80% revealed",
                                                  "30% to top, 80% revealed",
                                                  "81% True Positive",
                                                  "77% True Positive",
                                                  "69% True Positive",
                                                  "19% False Positive",
                                                  "23% False Positive",
                                                  "31% False Positive",
                                                  "19% False Negative",
                                                  "23% False Negative",
                                                  "31% False Negative",
                                                  "Forecast Error Not Provided",
                                                  "Plus or Minus 5",
                                                  "Plus or Minus 8",
                                                  "No Human",
                                                  "25% human",
                                                  "50% human",
                                                  "Private Firm",
                                                  "U.S. Department of Justice",
                                                  "Harvard University")))

results$estimate <- as.numeric(results$estimate)
results$cilo <- as.numeric(results$cilo)
results$cihi <- as.numeric(results$cihi)

p3 = ggplot(results[results$basecat != "I",]) + 
  geom_point(aes(condition, estimate)) +
  geom_errorbar(aes(x = condition, ymin=cilo, ymax=cihi), width=.1) +
  facet_grid(basecat ~ ., space="free_y", scales="free_y", switch="y") + 
  theme_classic() +
  theme(strip.placement = "outside",
        strip.background = element_rect(fill=NA, colour="grey50"),
        panel.spacing.x=unit(0,"cm")) + coord_flip() + geom_hline(yintercept = 0) +
  labs(x = "Condition", y = "Effect on Pr(Algorithm Acceptance)")
p3
ggsave(here("conjointGraphRate(Lucid).png"),
       plot = p3, device = "png", width = 4.5, height = 9.5)


